Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
(no description)
File Size: | 334 lines (16 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
HTML_QuickForm_RuleRegistry:: (6 methods):
singleton()
registerRule()
getRule()
validate()
getValidationScript()
_getJsValue()
Class: HTML_QuickForm_RuleRegistry - X-Ref
Registers rule objects and uses them for validationsingleton() X-Ref |
Returns a singleton of HTML_QuickForm_RuleRegistry Usually, only one RuleRegistry object is needed, this is the reason why it is recommended to use this method to get the validation object. return: object Reference to the HTML_QuickForm_RuleRegistry singleton |
registerRule($ruleName, $type, $data1, $data2 = null) X-Ref |
Registers a new validation rule In order to use a custom rule in your form, you need to register it first. For regular expressions, one can directly use the 'regex' type rule in addRule(), this is faster than registering the rule. Functions and methods can be registered. Use the 'function' type. When registering a method, specify the class name as second parameter. You can also register an HTML_QuickForm_Rule subclass with its own validate() method. return: void param: string $ruleName Name of validation rule param: string $type Either: 'regex', 'function' or null param: string $data1 Name of function, regular expression or param: string $data2 Object parent of above function or HTML_QuickForm_Rule file path |
getRule($ruleName) X-Ref |
Returns a reference to the requested rule object return: object param: string $ruleName Name of the requested rule |
validate($ruleName, $values, $options = null, $multiple = false) X-Ref |
Performs validation on the given values return: mixed true if no error found, int of valid values (when an array of values is given) or false if error param: string $ruleName Name of the rule to be used param: mixed $values Can be a scalar or an array of values param: mixed $options Options used by the rule param: mixed $multiple Whether to validate an array of values altogether |
getValidationScript(&$element, $elementName, $ruleData) X-Ref |
Returns the validation test in javascript code return: string JavaScript for the rule param: mixed Element(s) the rule applies to param: string Element name, in case $element is not array param: array Rule data |
_getJsValue(&$element, $elementName, $reset = false, $index = null) X-Ref |
Returns JavaScript to get and to reset the element's value return: array first item is value javascript, second is reset param: object HTML_QuickForm_element element being processed param: string element's name param: bool whether to generate JavaScript to reset the value param: integer value's index in the array (only used for multielement rules) |