|
Moodle
2.2.1
http://www.collinsharper.com
|


Public Member Functions | |
| HTML_QuickForm ($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit=false) | |
| apiVersion () | |
| registerElementType ($typeName, $include, $className) | |
| registerRule ($ruleName, $type, $data1, $data2=null) | |
| elementExists ($element=null) | |
| setDatasource (&$datasource, $defaultsFilter=null, $constantsFilter=null) | |
| setDefaults ($defaultValues=null, $filter=null) | |
| setConstants ($constantValues=null, $filter=null) | |
| setMaxFileSize ($bytes=0) | |
| getMaxFileSize () | |
| & | createElement ($elementType) |
| & | _loadElement ($event, $type, $args) |
| & | addElement ($element) |
| & | insertElementBefore (&$element, $nameAfter) |
| & | addGroup ($elements, $name=null, $groupLabel='', $separator=null, $appendName=true) |
| & | getElement ($element) |
| & | getElementValue ($element) |
| getSubmitValue ($elementName) | |
| _reindexFiles ($value, $key) | |
| getElementError ($element) | |
| setElementError ($element, $message=null) | |
| getElementType ($element) | |
| updateElementAttr ($elements, $attrs) | |
| & | removeElement ($elementName, $removeRules=true) |
| addRule ($element, $message, $type, $format=null, $validation='server', $reset=false, $force=false) | |
| addGroupRule ($group, $arg1, $type='', $format=null, $howmany=0, $validation= 'server', $reset=false) | |
| addFormRule ($rule) | |
| applyFilter ($element, $filter) | |
| _recursiveFilter ($filter, $value) | |
| arrayMerge ($a, $b) | |
| isTypeRegistered ($type) | |
| getRegisteredTypes () | |
| isRuleRegistered ($name, $autoRegister=false) | |
| getRegisteredRules () | |
| isElementRequired ($element) | |
| isElementFrozen ($element) | |
| setJsWarnings ($pref, $post) | |
| setRequiredNote ($note) | |
| getRequiredNote () | |
| validate () | |
| freeze ($elementList=null) | |
| isFrozen () | |
| process ($callback, $mergeFiles=true) | |
| accept (&$renderer) | |
| & | defaultRenderer () |
| toHtml ($in_data=null) | |
| getValidationScript () | |
| getSubmitValues ($mergeFiles=false) | |
| toArray ($collectHidden=false) | |
| exportValue ($element) | |
| exportValues ($elementList=null) | |
| isSubmitted () | |
| isError ($value) | |
| errorMessage ($value) | |
Data Fields | |
| $_elements = array() | |
| $_elementIndex = array() | |
| $_duplicateIndex = array() | |
| $_required = array() | |
| $_jsPrefix = 'Invalid information entered.' | |
| $_jsPostfix = 'Please correct these fields.' | |
| $_datasource | |
| $_defaultValues = array() | |
| $_constantValues = array() | |
| $_submitValues = array() | |
| $_submitFiles = array() | |
| $_maxFileSize = 1048576 | |
| $_freezeAll = false | |
| $_rules = array() | |
| $_formRules = array() | |
| $_errors = array() | |
| $_requiredNote = '<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>' | |
| $_flagSubmitted = false | |
Create, validate and process HTML forms
Definition at line 97 of file QuickForm.php.
| & _loadElement | ( | $ | event, |
| $ | type, | ||
| $ | args | ||
| ) |
Returns a form element of the given type
| string | $event | event to send to newly created element ('createElement' or 'addElement') |
| string | $type | element type |
| array | $args | arguments for event |
| HTML_QuickForm_Error |
Definition at line 556 of file QuickForm.php.


| _recursiveFilter | ( | $ | filter, |
| $ | value | ||
| ) |
Recursively apply a filter function
| string | $filter | filter to apply |
| mixed | $value | submitted values |
Definition at line 1233 of file QuickForm.php.

| _reindexFiles | ( | $ | value, |
| $ | key | ||
| ) |
A helper function to change the indexes in $_FILES array
| mixed | Some value from the $_FILES array |
| string | The key from the $_FILES array that should be appended |
Definition at line 862 of file QuickForm.php.

| accept | ( | &$ | renderer | ) |
Accepts a renderer
| object | An HTML_QuickForm_Renderer object |
Reimplemented in MoodleQuickForm.
Definition at line 1619 of file QuickForm.php.


| & addElement | ( | $ | element | ) |
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
| mixed | $element | element object or type of element to add (text, textarea, file...) |
| HTML_QuickForm_Error |
Definition at line 595 of file QuickForm.php.


| addFormRule | ( | $ | rule | ) |
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.
public
| mixed | Callback, either function name or array(&$object, 'method') |
| HTML_QuickForm_Error |
Definition at line 1177 of file QuickForm.php.

| & addGroup | ( | $ | elements, |
| $ | name = null, |
||
| $ | groupLabel = '', |
||
| $ | separator = null, |
||
| $ | appendName = true |
||
| ) |
Adds an element group
| array | $elements | array of elements composing the group |
| string | $name | (optional)group name |
| string | $groupLabel | (optional)group label |
| string | $separator | (optional)string to separate elements |
| string | $appendName | (optional)specify whether the group name should be used in the form element name ex: group[element] |
| PEAR_Error |
Definition at line 717 of file QuickForm.php.

| addGroupRule | ( | $ | group, |
| $ | arg1, | ||
| $ | type = '', |
||
| $ | format = null, |
||
| $ | howmany = 0, |
||
| $ | validation = 'server', |
||
| $ | reset = false |
||
| ) |
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.
| string | $group | Form group name |
| mixed | $arg1 | Array for multiple elements or error message string for one element |
| string | $type | (optional)Rule type use getRegisteredRules() to get types |
| string | $format | (optional)Required for extra rule data |
| int | $howmany | (optional)How many valid elements should be in the group |
| string | $validation | (optional)Where to perform validation: "server", "client" |
| bool | $reset | Client-side: whether to reset the element's value to its original state if validation failed. |
| HTML_QuickForm_Error |
Reimplemented in MoodleQuickForm.
Definition at line 1087 of file QuickForm.php.

| addRule | ( | $ | element, |
| $ | message, | ||
| $ | type, | ||
| $ | format = null, |
||
| $ | validation = 'server', |
||
| $ | reset = false, |
||
| $ | force = false |
||
| ) |
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.
| string | $element | Form element name |
| string | $message | Message to display for invalid data |
| string | $type | Rule type, use getRegisteredRules() to get types |
| string | $format | (optional)Required for extra rule data |
| string | $validation | (optional)Where to perform validation: "server", "client" |
| boolean | $reset | Client-side validation: reset the form element to its original value if there is an error? |
| boolean | $force | Force the rule to be applied, even if the target form element does not exist |
| HTML_QuickForm_Error |
Reimplemented in MoodleQuickForm.
Definition at line 1021 of file QuickForm.php.

| apiVersion | ( | ) |
Returns the current API version
Reimplemented from HTML_Common.
Definition at line 314 of file QuickForm.php.
| applyFilter | ( | $ | element, |
| $ | filter | ||
| ) |
Applies a data filter for the given field(s)
| mixed | $element | Form element name or array of such names |
| mixed | $filter | Callback, either function name or array(&$object, 'method') |
Definition at line 1196 of file QuickForm.php.

| arrayMerge | ( | $ | a, |
| $ | b | ||
| ) |
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.
puplic
| array | $a | original array |
| array | $b | array which will be merged into first one |
Definition at line 1261 of file QuickForm.php.

| & createElement | ( | $ | elementType | ) |
Creates a new form element of the given type.
This method accepts variable number of parameters, their meaning and count depending on $elementType
| string | $elementType | type of element to add (text, textarea, file...) |
| HTML_QuickForm_Error |
Definition at line 535 of file QuickForm.php.


| & defaultRenderer | ( | ) |
Returns a reference to default renderer object
public
Definition at line 1642 of file QuickForm.php.

| elementExists | ( | $ | element = null | ) |
Returns true if element is in the form
| string | $element | form name of element to check |
Definition at line 369 of file QuickForm.php.

| errorMessage | ( | $ | value | ) |
Return a textual error message for an QuickForm error code
public
| int | error code |
Definition at line 1926 of file QuickForm.php.


| exportValue | ( | $ | element | ) |
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.
| string | Name of an element public |
Definition at line 1822 of file QuickForm.php.


| exportValues | ( | $ | elementList = null | ) |
Returns 'safe' elements' values
Unlike getSubmitValues(), this will return only the values corresponding to the elements present in the form.
| mixed | Array/string of element names, whose values we want. If not set then return all elements. public |
| HTML_QuickForm_Error |
Reimplemented in MoodleQuickForm.
Definition at line 1856 of file QuickForm.php.

| freeze | ( | $ | elementList = null | ) |
Displays elements without HTML input tags
| mixed | $elementList | array or string of element(s) to be frozen |
| HTML_QuickForm_Error |
Definition at line 1546 of file QuickForm.php.

| & getElement | ( | $ | element | ) |
Returns a reference to the element
| string | $element | Element name |
| HTML_QuickForm_Error |
Definition at line 741 of file QuickForm.php.


| getElementError | ( | $ | element | ) |
Returns error corresponding to validated element
| string | $element | Name of form element to check |
Definition at line 886 of file QuickForm.php.

| getElementType | ( | $ | element | ) |
Returns the type of the given element
| string | $element | Name of form element |
Definition at line 925 of file QuickForm.php.

| & getElementValue | ( | $ | element | ) |
Returns the element's raw value
This returns the value as submitted by the form (not filtered) or set via setDefaults() or setConstants()
| string | $element | Element name |
| HTML_QuickForm_Error |
Definition at line 766 of file QuickForm.php.


| getMaxFileSize | ( | ) |
Returns the value of MAX_FILE_SIZE hidden element
Definition at line 515 of file QuickForm.php.
Returns an array of registered validation rules
Definition at line 1361 of file QuickForm.php.
Returns an array of registered element types
Definition at line 1306 of file QuickForm.php.
| getRequiredNote | ( | ) |
Returns the required note
Definition at line 1445 of file QuickForm.php.
| getSubmitValue | ( | $ | elementName | ) |
Returns the elements value after submit and filter
| string | Element name |
Definition at line 798 of file QuickForm.php.


| getSubmitValues | ( | $ | mergeFiles = false | ) |
Returns the values submitted by the form
| bool | Whether uploaded files should be returned too |
Definition at line 1782 of file QuickForm.php.

Returns the client side validation script
Reimplemented in MoodleQuickForm, and HTML_QuickForm_DHTMLRulesTableless.
Definition at line 1684 of file QuickForm.php.

| HTML_QuickForm | ( | $ | formName = '', |
| $ | method = 'post', |
||
| $ | action = '', |
||
| $ | target = '', |
||
| $ | attributes = null, |
||
| $ | trackSubmit = false |
||
| ) |
Class constructor
| string | $formName | Form's name. |
| string | $method | (optional)Form's method defaults to 'POST' |
| string | $action | (optional)Form's action |
| string | $target | (optional)Form's target defaults to '_self' |
| mixed | $attributes | (optional)Extra attributes for <form> tag |
| bool | $trackSubmit | (optional)Whether to track if the form was submitted by adding a special hidden field public |
Definition at line 256 of file QuickForm.php.

| & insertElementBefore | ( | &$ | element, |
| $ | nameAfter | ||
| ) |
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');
public
| object | HTML_QuickForm_element Element to insert |
| string | Name of the element before which the new one is inserted |
| HTML_QuickForm_Error |
Definition at line 650 of file QuickForm.php.

| isElementFrozen | ( | $ | element | ) |
Returns whether or not the form element is frozen
| string | $element | Form element name |
Definition at line 1393 of file QuickForm.php.
| isElementRequired | ( | $ | element | ) |
Returns whether or not the form element is required
| string | $element | Form element name |
Definition at line 1377 of file QuickForm.php.

| isError | ( | $ | value | ) |
Tell whether a result from a QuickForm method is an error (an instance of HTML_QuickForm_Error)
public
| mixed | result code |
Definition at line 1911 of file QuickForm.php.

| isFrozen | ( | ) |
Returns whether or not the whole form is frozen
Definition at line 1582 of file QuickForm.php.

| isRuleRegistered | ( | $ | name, |
| $ | autoRegister = false |
||
| ) |
Returns whether or not the given rule is supported
| string | $name | Validation rule name |
| bool | Whether to automatically register subclasses of HTML_QuickForm_Rule |
Definition at line 1323 of file QuickForm.php.


| isSubmitted | ( | ) |
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.
public
Reimplemented in MoodleQuickForm.
Definition at line 1895 of file QuickForm.php.

| isTypeRegistered | ( | $ | type | ) |
Returns whether or not the form element type is supported
| string | $type | Form element type |
Definition at line 1291 of file QuickForm.php.

Performs the form data processing
| mixed | $callback | Callback, either function name or array(&$object, 'method') |
| bool | $mergeFiles | Whether uploaded files should be processed too |
| HTML_QuickForm_Error |
Definition at line 1599 of file QuickForm.php.

| registerElementType | ( | $ | typeName, |
| $ | include, | ||
| $ | className | ||
| ) |
Registers a new element type
| string | $typeName | Name of element type |
| string | $include | Include path for element type |
| string | $className | Element class name |
Definition at line 332 of file QuickForm.php.
| registerRule | ( | $ | ruleName, |
| $ | type, | ||
| $ | data1, | ||
| $ | data2 = null |
||
| ) |
Registers a new validation rule
| string | $ruleName | Name of validation rule |
| string | $type | Either: 'regex', 'function' or 'rule' for an HTML_QuickForm_Rule object |
| string | $data1 | Name of function, regular expression or HTML_QuickForm_Rule classname |
| string | $data2 | Object parent of above function or HTML_QuickForm_Rule file path |
Definition at line 351 of file QuickForm.php.

| & removeElement | ( | $ | elementName, |
| $ | removeRules = true |
||
| ) |
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.
| string | $elementName | The element name |
| boolean | $removeRules | True if rules for this element are to be removed too public |
| HTML_QuickForm_Error |
Definition at line 981 of file QuickForm.php.

| setConstants | ( | $ | constantValues = null, |
| $ | filter = null |
||
| ) |
Initializes constant form values. These values won't get overridden by POST or GET vars
| array | $constantValues | values used to fill the form |
| mixed | $filter | (optional) filter(s) to apply to all default values |
Definition at line 456 of file QuickForm.php.


| setDatasource | ( | &$ | datasource, |
| $ | defaultsFilter = null, |
||
| $ | constantsFilter = null |
||
| ) |
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.
| object | $datasource | datasource object implementing the informal datasource protocol |
| mixed | $defaultsFilter | string or array of filter(s) to apply to default values |
| mixed | $constantsFilter | string or array of filter(s) to apply to constants values |
Definition at line 390 of file QuickForm.php.

| setDefaults | ( | $ | defaultValues = null, |
| $ | filter = null |
||
| ) |
Initializes default form values
| array | $defaultValues | values used to fill the form |
| mixed | $filter | (optional) filter(s) to apply to all default values |
Definition at line 417 of file QuickForm.php.


| setElementError | ( | $ | element, |
| $ | message = null |
||
| ) |
Set error message for a form element
| string | $element | Name of form element to set error for |
| string | $message | Error message, if empty then removes the current error message |
Definition at line 905 of file QuickForm.php.
| setJsWarnings | ( | $ | pref, |
| $ | post | ||
| ) |
Sets JavaScript warning messages
| string | $pref | Prefix warning |
| string | $post | Postfix warning |
Definition at line 1413 of file QuickForm.php.
| setMaxFileSize | ( | $ | bytes = 0 | ) |
Sets the value of MAX_FILE_SIZE hidden element
| int | $bytes | Size in bytes |
Definition at line 492 of file QuickForm.php.

| setRequiredNote | ( | $ | note | ) |
Sets required-note
| string | $note | Message indicating some elements are required |
Definition at line 1430 of file QuickForm.php.
| toArray | ( | $ | collectHidden = false | ) |
Returns the form's contents in an array.
The description of the array structure is in HTML_QuickForm_Renderer_Array docs
| bool | Whether to collect hidden elements (passed to the Renderer's constructor) |
Definition at line 1800 of file QuickForm.php.

| toHtml | ( | $ | in_data = null | ) |
Returns an HTML version of the form
| string | $in_data | (optional) Any extra data to insert right before form is rendered. Useful when using templates. |
Definition at line 1664 of file QuickForm.php.

| updateElementAttr | ( | $ | elements, |
| $ | attrs | ||
| ) |
Updates Attributes for one or more elements
| mixed | $elements | Array of element names/objects or string of elements to be updated |
| mixed | $attrs | Array or sting of html attributes |
Definition at line 945 of file QuickForm.php.
| validate | ( | ) |
Performs the server side validation public
Definition at line 1459 of file QuickForm.php.

| $_constantValues = array() |
Definition at line 171 of file QuickForm.php.
| $_datasource |
Definition at line 155 of file QuickForm.php.
| $_defaultValues = array() |
Definition at line 163 of file QuickForm.php.
| $_duplicateIndex = array() |
Definition at line 122 of file QuickForm.php.
| $_elementIndex = array() |
Definition at line 114 of file QuickForm.php.
| $_elements = array() |
Definition at line 106 of file QuickForm.php.
| $_errors = array() |
Definition at line 226 of file QuickForm.php.
| $_flagSubmitted = false |
Definition at line 241 of file QuickForm.php.
| $_formRules = array() |
Definition at line 218 of file QuickForm.php.
| $_freezeAll = false |
Definition at line 203 of file QuickForm.php.
| $_jsPostfix = 'Please correct these fields.' |
Definition at line 146 of file QuickForm.php.
| $_jsPrefix = 'Invalid information entered.' |
Definition at line 138 of file QuickForm.php.
| $_maxFileSize = 1048576 |
Definition at line 195 of file QuickForm.php.
| $_required = array() |
Definition at line 130 of file QuickForm.php.
| $_requiredNote = '<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>' |
Definition at line 234 of file QuickForm.php.
| $_rules = array() |
Definition at line 211 of file QuickForm.php.
| $_submitFiles = array() |
Definition at line 187 of file QuickForm.php.
| $_submitValues = array() |
Definition at line 179 of file QuickForm.php.