How to validate with PHP code
This tutorial shows you how to validate fields on form by using validation component and PHP Code. In our example we will validate form for registration.
1. Login into developer panel of application.
2. Click on Pages menu item.
3. Select page pageRegistrationCustomer.
4. Drag and drop Validation component from all components list to button for registration named ButtonRegister. So when someone click on button Register, form will be validated first.
5. In dropped validation component properties, for Data source type property choose PHP Code. Click on Data source PHP field and enter your PHP code. Variable result is an instance of AjaxProxy class. This variable is already instantiated. Attribute status of result variable ($result->status) can be true or false. If there is no errors in validation, we set attribute status to true. If attribute status is false, we can use attribute error ($result->error) to show error message in application. You can also set custom error message for every component on form by using validationMessages attribute (i.e. $result->validationMessages = “NameOfComponent1|Error for component 1.;NameOfComponent2|Error for component2.;”). Click on Save button.
6. Click on Save changes, go into your application and check out the results.