A customizable validation rule. Runs PHP code to test for validation success or failure
- Error message - The message to display next to the element if the validation fails. This text should explain why the validation failed and what steps the user should take to remedy the error.
- Condition - A PHP expression which if returns false, means that the validation is not run.
- PHP -PHP code to run.
- If it returns 'true' then the validation is successful,
- if it returns false then the validation fails.
- The element's submitted value is found in the variable $data.
- You can also return a string which can be used if the 'Match or replace' option is set to 'replace'
- Match or Replace - If set to match then the validation behaves as normal and on validation failure returns you to the form showing the error message. If set to 'replace' then the submitted value is replaced with the data returned from the 'PHP code' script
- Tip text - additonal informational text which is displayed as a tip when the user hovers over the element's label. This can provide specific information about the validation, enabling the user to correctly fill in the field.
Examples (top)Ensure a date elements value (stored in the value $data) is greater than another's whose full element name is 'tablename___elementname':
Set a custom error message(top)
As of 14/08/2013 (fabrik 3.0.x and 3.1) you can do this....
$this->setMessage('oh dear you can not do that!');
repeat group data(top)
When your element is in a repeating group, then the placeholder contains the value for the current repeat group's values.
For example you have a form with a repeat group 'regions' and within that group you have a field 'regions___label'. Lets say the form is submitted with two repeat groups, in the first repeat group the label is 'Warwickshire' and in the second group the label is 'Yorkshire'.
If you add the following code as your validation:
 => Warwickshire
 => Yorkshire