|
You can format field values by adding PHP code.
Input value is stored in the variable $value. Output value is assigned to
the same variable $value.
You can access other fields of the same data record as $data["FieldName"].
Examples:
1. Convert a string into the upper case:
|
$value = strtoupper($value);
|
2. Format 10-digit phone number into the following format (xxx)
xxx-xxx:
|
if (strlen($value)==10)
{
$value="(" . substr($value,0,3) . ") " . substr($value,3,3) . "-" . substr($value,6);
}
|
3. Display value of field FirstName as <FirstName> <LastName> (if
LastName field
defined):
|
if ($data["LastName"])
$value = $value." ".$data["LastName"];
|
4. Display a number in black color if number is positive and red
font if number is negative:
|
if ($value>0)
$color="black";
else
$color="red";
$value="<font color='$color'>$value</font>";
|
5. Display a field containing email address as email hyperlink
(mailto function used). The
value of subject in mailto
function is set to a value of another field:
|
$value = "<a href='mailto:".$value."?subject=".$data["SubjectField"]."'>Send email</a>";
|
6. Display a field value in one line (without line breaks):
|
$value =
str_replace(" ",
" ",$value);
|
|