Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
Static utility methods.
File Size: | 2020 lines (77 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
HTML_QuickForm:: (2 methods):
__construct()
HTML_QuickForm()
name:: (53 methods):
apiVersion()
registerElementType()
registerRule()
elementExists()
setDatasource()
setDefaults()
setConstants()
setMaxFileSize()
getMaxFileSize()
createElement()
_loadElement()
addElement()
insertElementBefore()
addGroup()
getElement()
getElementValue()
getSubmitValue()
_reindexFiles()
getElementError()
setElementError()
getElementType()
updateElementAttr()
removeElement()
addRule()
addGroupRule()
addFormRule()
applyFilter()
_recursiveFilter()
arrayMerge()
isTypeRegistered()
getRegisteredTypes()
isRuleRegistered()
getRegisteredRules()
isElementRequired()
isElementFrozen()
setJsWarnings()
setRequiredNote()
getRequiredNote()
validate()
freeze()
isFrozen()
process()
accept()
defaultRenderer()
toHtml()
getValidationScript()
getSubmitValues()
toArray()
exportValue()
exportValues()
isSubmitted()
isError()
errorMessage()
HTML_QuickForm_Error:: (2 methods):
__construct()
HTML_QuickForm_Error()
name:: (53 methods):
apiVersion()
registerElementType()
registerRule()
elementExists()
setDatasource()
setDefaults()
setConstants()
setMaxFileSize()
getMaxFileSize()
createElement()
_loadElement()
addElement()
insertElementBefore()
addGroup()
getElement()
getElementValue()
getSubmitValue()
_reindexFiles()
getElementError()
setElementError()
getElementType()
updateElementAttr()
removeElement()
addRule()
addGroupRule()
addFormRule()
applyFilter()
_recursiveFilter()
arrayMerge()
isTypeRegistered()
getRegisteredTypes()
isRuleRegistered()
getRegisteredRules()
isElementRequired()
isElementFrozen()
setJsWarnings()
setRequiredNote()
getRequiredNote()
validate()
freeze()
isFrozen()
process()
accept()
defaultRenderer()
toHtml()
getValidationScript()
getSubmitValues()
toArray()
exportValue()
exportValues()
isSubmitted()
isError()
errorMessage()
Class: HTML_QuickForm - X-Ref
Create, validate and process HTML forms__construct($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) X-Ref |
Class constructor param: string $formName Form's name. param: string $method (optional)Form's method defaults to 'POST' param: string $action (optional)Form's action param: string $target (optional)Form's target defaults to '_self' param: mixed $attributes (optional)Extra attributes for <form> tag param: bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field |
HTML_QuickForm($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) X-Ref |
Old syntax of class constructor. Deprecated in PHP7. |
apiVersion() X-Ref |
Returns the current API version return: float |
registerElementType($typeName, $include, $className) X-Ref |
Registers a new element type param: string $typeName Name of element type param: string $include Include path for element type param: string $className Element class name return: void |
registerRule($ruleName, $type, $data1, $data2 = null) X-Ref |
Registers a new validation rule param: string $ruleName Name of validation rule param: string $type Either: 'regex', 'function' or 'rule' for an HTML_QuickForm_Rule object param: string $data1 Name of function, regular expression or HTML_QuickForm_Rule classname param: string $data2 Object parent of above function or HTML_QuickForm_Rule file path return: void |
elementExists($element=null) X-Ref |
Returns true if element is in the form param: string $element form name of element to check return: boolean |
setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = null) X-Ref |
Sets a datasource object for this form object Datasource default and constant values will feed the QuickForm object if the datasource implements defaultValues() and constantValues() methods. param: object $datasource datasource object implementing the informal datasource protocol param: mixed $defaultsFilter string or array of filter(s) to apply to default values param: mixed $constantsFilter string or array of filter(s) to apply to constants values return: void |
setDefaults($defaultValues = null, $filter = null) X-Ref |
Initializes default form values param: array $defaultValues values used to fill the form param: mixed $filter (optional) filter(s) to apply to all default values return: void |
setConstants($constantValues = null, $filter = null) X-Ref |
Initializes constant form values. These values won't get overridden by POST or GET vars param: array $constantValues values used to fill the form param: mixed $filter (optional) filter(s) to apply to all default values return: void |
setMaxFileSize($bytes = 0) X-Ref |
Sets the value of MAX_FILE_SIZE hidden element param: int $bytes Size in bytes return: void |
getMaxFileSize() X-Ref |
Returns the value of MAX_FILE_SIZE hidden element return: int max file size in bytes |
createElement($elementType) X-Ref |
Creates a new form element of the given type. This method accepts variable number of parameters, their meaning and count depending on $elementType param: string $elementType type of element to add (text, textarea, file...) return: object extended class of HTML_element |
_loadElement($event, $type, $args) X-Ref |
Returns a form element of the given type param: string $event event to send to newly created element ('createElement' or 'addElement') param: string $type element type param: array $args arguments for event return: object a new element |
addElement($element) X-Ref |
Adds an element into the form If $element is a string representing element type, then this method accepts variable number of parameters, their meaning and count depending on $element param: mixed $element element object or type of element to add (text, textarea, file...) return: object reference to element |
insertElementBefore(&$element, $nameAfter) X-Ref |
Inserts a new element right before the other element Warning: it is not possible to check whether the $element is already added to the form, therefore if you want to move the existing form element to a new position, you'll have to use removeElement(): $form->insertElementBefore($form->removeElement('foo', false), 'bar'); param: object HTML_QuickForm_element Element to insert param: string Name of the element before which the new one is inserted return: object HTML_QuickForm_element reference to inserted element |
addGroup($elements, $name = null, $groupLabel = '', $separator = null, $appendName = true, $attributes = null) X-Ref |
Adds an element group param: array $elements array of elements composing the group param: string $name (optional)group name param: string $groupLabel (optional)group label param: string $separator (optional)string to separate elements param: bool $appendName (optional)specify whether the group name should be param: mixed $attributes Either a typical HTML attribute string or an associative array return: object reference to added group of elements |
getElement($element) X-Ref |
Returns a reference to the element param: string $element Element name return: object reference to element |
getElementValue($element) X-Ref |
Returns the element's raw value This returns the value as submitted by the form (not filtered) or set via setDefaults() or setConstants() param: string $element Element name return: mixed element value |
getSubmitValue($elementName) X-Ref |
Returns the elements value after submit and filter param: string Element name return: mixed submitted element value or null if not set |
_reindexFiles($value, $key) X-Ref |
A helper function to change the indexes in $_FILES array param: mixed Some value from the $_FILES array param: string The key from the $_FILES array that should be appended return: array |
getElementError($element) X-Ref |
Returns error corresponding to validated element param: string $element Name of form element to check return: string error message corresponding to checked element |
setElementError($element, $message = null) X-Ref |
Set error message for a form element param: string $element Name of form element to set error for param: string $message Error message, if empty then removes the current error message return: void |
getElementType($element) X-Ref |
Returns the type of the given element param: string $element Name of form element return: string Type of the element, false if the element is not found |
updateElementAttr($elements, $attrs) X-Ref |
Updates Attributes for one or more elements param: mixed $elements Array of element names/objects or string of elements to be updated param: mixed $attrs Array or sting of html attributes return: void |
removeElement($elementName, $removeRules = true) X-Ref |
Removes an element The method "unlinks" an element from the form, returning the reference to the element object. If several elements named $elementName exist, it removes the first one, leaving the others intact. param: string $elementName The element name param: boolean $removeRules True if rules for this element are to be removed too return: object HTML_QuickForm_element a reference to the removed element |
addRule($element, $message, $type, $format=null, $validation='server', $reset = false, $force = false) X-Ref |
Adds a validation rule for the given field If the element is in fact a group, it will be considered as a whole. To validate grouped elements as separated entities, use addGroupRule instead of addRule. param: string $element Form element name param: string $message Message to display for invalid data param: string $type Rule type, use getRegisteredRules() to get types param: string $format (optional)Required for extra rule data param: string $validation (optional)Where to perform validation: "server", "client" param: boolean $reset Client-side validation: reset the form element to its original value if there is an error? param: boolean $force Force the rule to be applied, even if the target form element does not exist |
addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false) X-Ref |
Adds a validation rule for the given group of elements Only groups with a name can be assigned a validation rule Use addGroupRule when you need to validate elements inside the group. Use addRule if you need to validate the group as a whole. In this case, the same rule will be applied to all elements in the group. Use addRule if you need to validate the group against a function. param: string $group Form group name param: mixed $arg1 Array for multiple elements or error message string for one element param: string $type (optional)Rule type use getRegisteredRules() to get types param: string $format (optional)Required for extra rule data param: int $howmany (optional)How many valid elements should be in the group param: string $validation (optional)Where to perform validation: "server", "client" param: bool $reset Client-side: whether to reset the element's value to its original state if validation failed. |
addFormRule($rule) X-Ref |
Adds a global validation rule This should be used when for a rule involving several fields or if you want to use some completely custom validation for your form. The rule function/method should return true in case of successful validation and array('element name' => 'error') when there were errors. param: mixed Callback, either function name or array(&$object, 'method') |
applyFilter($element, $filter) X-Ref |
Applies a data filter for the given field(s) param: mixed $element Form element name or array of such names param: mixed $filter Callback, either function name or array(&$object, 'method') |
_recursiveFilter($filter, $value) X-Ref |
Recursively apply a filter function param: string $filter filter to apply param: mixed $value submitted values return: cleaned values |
arrayMerge($a, $b) X-Ref |
Merges two arrays Merges two array like the PHP function array_merge but recursively. The main difference is that existing keys will not be renumbered if they are integers. param: array $a original array param: array $b array which will be merged into first one return: array merged array |
isTypeRegistered($type) X-Ref |
Returns whether or not the form element type is supported param: string $type Form element type return: boolean |
getRegisteredTypes() X-Ref |
Returns an array of registered element types return: array |
isRuleRegistered($name, $autoRegister = false) X-Ref |
Returns whether or not the given rule is supported param: string $name Validation rule name param: bool Whether to automatically register subclasses of HTML_QuickForm_Rule return: mixed true if previously registered, false if not, new rule name if auto-registering worked |
getRegisteredRules() X-Ref |
Returns an array of registered validation rules return: array |
isElementRequired($element) X-Ref |
Returns whether or not the form element is required param: string $element Form element name return: boolean |
isElementFrozen($element) X-Ref |
Returns whether or not the form element is frozen param: string $element Form element name return: boolean |
setJsWarnings($pref, $post) X-Ref |
Sets JavaScript warning messages param: string $pref Prefix warning param: string $post Postfix warning return: void |
setRequiredNote($note) X-Ref |
Sets required-note param: string $note Message indicating some elements are required return: void |
getRequiredNote() X-Ref |
Returns the required note return: string |
validate() X-Ref |
Performs the server side validation return: boolean true if no error found |
freeze($elementList=null) X-Ref |
Displays elements without HTML input tags param: mixed $elementList array or string of element(s) to be frozen |
isFrozen() X-Ref |
Returns whether or not the whole form is frozen return: boolean |
process($callback, $mergeFiles = true) X-Ref |
Performs the form data processing param: mixed $callback Callback, either function name or array(&$object, 'method') param: bool $mergeFiles Whether uploaded files should be processed too |
accept(&$renderer) X-Ref |
Accepts a renderer param: object An HTML_QuickForm_Renderer object return: void |
defaultRenderer() X-Ref |
Returns a reference to default renderer object return: object a default renderer object |
toHtml($in_data = null) X-Ref |
Returns an HTML version of the form param: string $in_data (optional) Any extra data to insert right return: string Html version of the form |
getValidationScript() X-Ref |
Returns the client side validation script return: string Javascript to perform validation, empty string if no 'client' rules were added |
getSubmitValues($mergeFiles = false) X-Ref |
Returns the values submitted by the form param: bool Whether uploaded files should be returned too return: array |
toArray($collectHidden = false) X-Ref |
Returns the form's contents in an array. The description of the array structure is in HTML_QuickForm_Renderer_Array docs param: bool Whether to collect hidden elements (passed to the Renderer's constructor) return: array of form contents |
exportValue($element) X-Ref |
Returns a 'safe' element's value This method first tries to find a cleaned-up submitted value, it will return a value set by setValue()/setDefaults()/setConstants() if submitted value does not exist for the given element. param: string Name of an element return: mixed |
exportValues($elementList = null) X-Ref |
Returns 'safe' elements' values Unlike getSubmitValues(), this will return only the values corresponding to the elements present in the form. param: mixed Array/string of element names, whose values we want. If not set then return all elements. return: array An assoc array of elements' values |
isSubmitted() X-Ref |
Tells whether the form was already submitted This is useful since the _submitFiles and _submitValues arrays may be completely empty after the trackSubmit value is removed. return: bool |
isError($value) X-Ref |
Tell whether a result from a QuickForm method is an error (an instance of HTML_QuickForm_Error) param: mixed result code return: bool whether $value is an error |
errorMessage($value) X-Ref |
Return a textual error message for an QuickForm error code param: int error code return: string error message |
Class: HTML_QuickForm_Error - X-Ref
__construct($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN,$level = E_USER_NOTICE, $debuginfo = null) X-Ref |
Creates a quickform error object, extending the PEAR_Error class param: int $code the error code param: int $mode the reaction to the error, either return, die or trigger/callback param: int $level intensity of the error (PHP error code) param: mixed $debuginfo any information that can inform user as to nature of the error |
HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN,$level = E_USER_NOTICE, $debuginfo = null) X-Ref |
Old syntax of class constructor. Deprecated in PHP7. |
apiVersion() X-Ref |
Returns the current API version return: float |
registerElementType($typeName, $include, $className) X-Ref |
Registers a new element type param: string $typeName Name of element type param: string $include Include path for element type param: string $className Element class name return: void |
registerRule($ruleName, $type, $data1, $data2 = null) X-Ref |
Registers a new validation rule param: string $ruleName Name of validation rule param: string $type Either: 'regex', 'function' or 'rule' for an HTML_QuickForm_Rule object param: string $data1 Name of function, regular expression or HTML_QuickForm_Rule classname param: string $data2 Object parent of above function or HTML_QuickForm_Rule file path return: void |
elementExists($element=null) X-Ref |
Returns true if element is in the form param: string $element form name of element to check return: boolean |
setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = null) X-Ref |
Sets a datasource object for this form object Datasource default and constant values will feed the QuickForm object if the datasource implements defaultValues() and constantValues() methods. param: object $datasource datasource object implementing the informal datasource protocol param: mixed $defaultsFilter string or array of filter(s) to apply to default values param: mixed $constantsFilter string or array of filter(s) to apply to constants values return: void |
setDefaults($defaultValues = null, $filter = null) X-Ref |
Initializes default form values param: array $defaultValues values used to fill the form param: mixed $filter (optional) filter(s) to apply to all default values return: void |
setConstants($constantValues = null, $filter = null) X-Ref |
Initializes constant form values. These values won't get overridden by POST or GET vars param: array $constantValues values used to fill the form param: mixed $filter (optional) filter(s) to apply to all default values return: void |
setMaxFileSize($bytes = 0) X-Ref |
Sets the value of MAX_FILE_SIZE hidden element param: int $bytes Size in bytes return: void |
getMaxFileSize() X-Ref |
Returns the value of MAX_FILE_SIZE hidden element return: int max file size in bytes |
createElement($elementType) X-Ref |
Creates a new form element of the given type. This method accepts variable number of parameters, their meaning and count depending on $elementType param: string $elementType type of element to add (text, textarea, file...) return: object extended class of HTML_element |
_loadElement($event, $type, $args) X-Ref |
Returns a form element of the given type param: string $event event to send to newly created element ('createElement' or 'addElement') param: string $type element type param: array $args arguments for event return: object a new element |
addElement($element) X-Ref |
Adds an element into the form If $element is a string representing element type, then this method accepts variable number of parameters, their meaning and count depending on $element param: mixed $element element object or type of element to add (text, textarea, file...) return: object reference to element |
insertElementBefore(&$element, $nameAfter) X-Ref |
Inserts a new element right before the other element Warning: it is not possible to check whether the $element is already added to the form, therefore if you want to move the existing form element to a new position, you'll have to use removeElement(): $form->insertElementBefore($form->removeElement('foo', false), 'bar'); param: object HTML_QuickForm_element Element to insert param: string Name of the element before which the new one is inserted return: object HTML_QuickForm_element reference to inserted element |
addGroup($elements, $name = null, $groupLabel = '', $separator = null, $appendName = true, $attributes = null) X-Ref |
Adds an element group param: array $elements array of elements composing the group param: string $name (optional)group name param: string $groupLabel (optional)group label param: string $separator (optional)string to separate elements param: bool $appendName (optional)specify whether the group name should be param: mixed $attributes Either a typical HTML attribute string or an associative array return: object reference to added group of elements |
getElement($element) X-Ref |
Returns a reference to the element param: string $element Element name return: object reference to element |
getElementValue($element) X-Ref |
Returns the element's raw value This returns the value as submitted by the form (not filtered) or set via setDefaults() or setConstants() param: string $element Element name return: mixed element value |
getSubmitValue($elementName) X-Ref |
Returns the elements value after submit and filter param: string Element name return: mixed submitted element value or null if not set |
_reindexFiles($value, $key) X-Ref |
A helper function to change the indexes in $_FILES array param: mixed Some value from the $_FILES array param: string The key from the $_FILES array that should be appended return: array |
getElementError($element) X-Ref |
Returns error corresponding to validated element param: string $element Name of form element to check return: string error message corresponding to checked element |
setElementError($element, $message = null) X-Ref |
Set error message for a form element param: string $element Name of form element to set error for param: string $message Error message, if empty then removes the current error message return: void |
getElementType($element) X-Ref |
Returns the type of the given element param: string $element Name of form element return: string Type of the element, false if the element is not found |
updateElementAttr($elements, $attrs) X-Ref |
Updates Attributes for one or more elements param: mixed $elements Array of element names/objects or string of elements to be updated param: mixed $attrs Array or sting of html attributes return: void |
removeElement($elementName, $removeRules = true) X-Ref |
Removes an element The method "unlinks" an element from the form, returning the reference to the element object. If several elements named $elementName exist, it removes the first one, leaving the others intact. param: string $elementName The element name param: boolean $removeRules True if rules for this element are to be removed too return: object HTML_QuickForm_element a reference to the removed element |
addRule($element, $message, $type, $format=null, $validation='server', $reset = false, $force = false) X-Ref |
Adds a validation rule for the given field If the element is in fact a group, it will be considered as a whole. To validate grouped elements as separated entities, use addGroupRule instead of addRule. param: string $element Form element name param: string $message Message to display for invalid data param: string $type Rule type, use getRegisteredRules() to get types param: string $format (optional)Required for extra rule data param: string $validation (optional)Where to perform validation: "server", "client" param: boolean $reset Client-side validation: reset the form element to its original value if there is an error? param: boolean $force Force the rule to be applied, even if the target form element does not exist |
addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false) X-Ref |
Adds a validation rule for the given group of elements Only groups with a name can be assigned a validation rule Use addGroupRule when you need to validate elements inside the group. Use addRule if you need to validate the group as a whole. In this case, the same rule will be applied to all elements in the group. Use addRule if you need to validate the group against a function. param: string $group Form group name param: mixed $arg1 Array for multiple elements or error message string for one element param: string $type (optional)Rule type use getRegisteredRules() to get types param: string $format (optional)Required for extra rule data param: int $howmany (optional)How many valid elements should be in the group param: string $validation (optional)Where to perform validation: "server", "client" param: bool $reset Client-side: whether to reset the element's value to its original state if validation failed. |
addFormRule($rule) X-Ref |
Adds a global validation rule This should be used when for a rule involving several fields or if you want to use some completely custom validation for your form. The rule function/method should return true in case of successful validation and array('element name' => 'error') when there were errors. param: mixed Callback, either function name or array(&$object, 'method') |
applyFilter($element, $filter) X-Ref |
Applies a data filter for the given field(s) param: mixed $element Form element name or array of such names param: mixed $filter Callback, either function name or array(&$object, 'method') |
_recursiveFilter($filter, $value) X-Ref |
Recursively apply a filter function param: string $filter filter to apply param: mixed $value submitted values return: cleaned values |
arrayMerge($a, $b) X-Ref |
Merges two arrays Merges two array like the PHP function array_merge but recursively. The main difference is that existing keys will not be renumbered if they are integers. param: array $a original array param: array $b array which will be merged into first one return: array merged array |
isTypeRegistered($type) X-Ref |
Returns whether or not the form element type is supported param: string $type Form element type return: boolean |
getRegisteredTypes() X-Ref |
Returns an array of registered element types return: array |
isRuleRegistered($name, $autoRegister = false) X-Ref |
Returns whether or not the given rule is supported param: string $name Validation rule name param: bool Whether to automatically register subclasses of HTML_QuickForm_Rule return: mixed true if previously registered, false if not, new rule name if auto-registering worked |
getRegisteredRules() X-Ref |
Returns an array of registered validation rules return: array |
isElementRequired($element) X-Ref |
Returns whether or not the form element is required param: string $element Form element name return: boolean |
isElementFrozen($element) X-Ref |
Returns whether or not the form element is frozen param: string $element Form element name return: boolean |
setJsWarnings($pref, $post) X-Ref |
Sets JavaScript warning messages param: string $pref Prefix warning param: string $post Postfix warning return: void |
setRequiredNote($note) X-Ref |
Sets required-note param: string $note Message indicating some elements are required return: void |
getRequiredNote() X-Ref |
Returns the required note return: string |
validate() X-Ref |
Performs the server side validation return: boolean true if no error found |
freeze($elementList=null) X-Ref |
Displays elements without HTML input tags param: mixed $elementList array or string of element(s) to be frozen |
isFrozen() X-Ref |
Returns whether or not the whole form is frozen return: boolean |
process($callback, $mergeFiles = true) X-Ref |
Performs the form data processing param: mixed $callback Callback, either function name or array(&$object, 'method') param: bool $mergeFiles Whether uploaded files should be processed too |
accept(&$renderer) X-Ref |
Accepts a renderer param: object An HTML_QuickForm_Renderer object return: void |
defaultRenderer() X-Ref |
Returns a reference to default renderer object return: object a default renderer object |
toHtml($in_data = null) X-Ref |
Returns an HTML version of the form param: string $in_data (optional) Any extra data to insert right return: string Html version of the form |
getValidationScript() X-Ref |
Returns the client side validation script return: string Javascript to perform validation, empty string if no 'client' rules were added |
getSubmitValues($mergeFiles = false) X-Ref |
Returns the values submitted by the form param: bool Whether uploaded files should be returned too return: array |
toArray($collectHidden = false) X-Ref |
Returns the form's contents in an array. The description of the array structure is in HTML_QuickForm_Renderer_Array docs param: bool Whether to collect hidden elements (passed to the Renderer's constructor) return: array of form contents |
exportValue($element) X-Ref |
Returns a 'safe' element's value This method first tries to find a cleaned-up submitted value, it will return a value set by setValue()/setDefaults()/setConstants() if submitted value does not exist for the given element. param: string Name of an element return: mixed |
exportValues($elementList = null) X-Ref |
Returns 'safe' elements' values Unlike getSubmitValues(), this will return only the values corresponding to the elements present in the form. param: mixed Array/string of element names, whose values we want. If not set then return all elements. return: array An assoc array of elements' values |
isSubmitted() X-Ref |
Tells whether the form was already submitted This is useful since the _submitFiles and _submitValues arrays may be completely empty after the trackSubmit value is removed. return: bool |
isError($value) X-Ref |
Tell whether a result from a QuickForm method is an error (an instance of HTML_QuickForm_Error) param: mixed result code return: bool whether $value is an error |
errorMessage($value) X-Ref |
Return a textual error message for an QuickForm error code param: int error code return: string error message |