Validation and filters
Вернуться к: Working with elements' values
- Introduction - validation and filters — How to process submitted data
- HTML_QuickForm::addRule() — Adds a validation rule for the given field
- HTML_QuickForm::addGroupRule() — Adds a validation rule for the given group
- HTML_QuickForm::addFormRule() — Adds a global validation rule
- HTML_QuickForm::isElementRequired() — Returns whether the form element is required
- HTML_QuickForm::validate() — Performs the server side validation
- HTML_QuickForm::getElementError() — Returns error corresponding to validated element
- HTML_QuickForm::setElementError() — Set error message for a form element
- HTML_QuickForm::registerRule() — Registers a new validation rule
- HTML_QuickForm::getRegisteredRules() — Returns registered validation rules
- HTML_QuickForm::isRuleRegistered() — Returns whether the rule is supported
- HTML_QuickForm::applyFilter() — Applies a filter for the given field(s)
QuickForm also provides validation rules support. You can code your own validation rules, register them in QuickForm and then call them in your script. By default, QuickForm can handle validation against regular expressions (preg_match style) and check for required elements. If you want client-side validation, QuickForm can generate the javascript code needed. Server-side validation is always on by default.
QuickForm can also make use of filters for data import into the form or for data processing once the form has been submitted. Filters work the same way as rules except that you don't need to register them. You write your filter functions and call them in your script. You can call any php function (ie. trim, addslashes, htmlentities, etc.) and have them applied recursively to your element values.
Вернуться к: Working with elements' values