Moodle  2.2.1
http://www.collinsharper.com
MoodleQuickForm Class Reference
Inheritance diagram for MoodleQuickForm:
Collaboration diagram for MoodleQuickForm:

Public Member Functions

 MoodleQuickForm ($formName, $method, $action, $target='', $attributes=null)
 setAdvanced ($elementName, $advanced=true)
 setShowAdvanced ($showadvancedNow=null)
 getShowAdvanced ()
 accept (&$renderer)
 closeHeaderBefore ($elementName)
 setType ($elementname, $paramtype)
 setTypes ($paramtypes)
 updateSubmission ($submission, $files)
 getReqHTML ()
 getAdvancedHTML ()
 setDefault ($elementName, $defaultValue)
 setHelpButtons ($buttons, $suppresscheck=false, $function='helpbutton')
 setHelpButton ($elementname, $buttonargs, $suppresscheck=false, $function='helpbutton')
 addHelpButton ($elementname, $identifier, $component= 'moodle', $linktext= '', $suppresscheck=false)
 setConstant ($elname, $value)
 exportValues ($elementList=null)
 addRule ($element, $message, $type, $format=null, $validation='server', $reset=false, $force=false)
 addGroupRule ($group, $arg1, $type='', $format=null, $howmany=0, $validation= 'server', $reset=false)
 getValidationScript ()
 _setDefaultRuleMessages ()
 getLockOptionObject ()
 _getElNamesRecursive ($element)
 disabledIf ($elementName, $dependentOn, $condition= 'notchecked', $value='1')
 registerNoSubmitButton ($buttonname)
 isNoSubmitButton ($buttonname)
 _registerCancelButton ($addfieldsname)
 hardFreeze ($elementList=null)
 hardFreezeAllVisibleExcept ($elementList)
 isSubmitted ()

Data Fields

 $_types = array()
 $_dependencies = array()
 $_noSubmitButtons = array()
 $_cancelButtons = array()
 $_advancedElements = array()
 $_showAdvanced = null
 $_formName = ''
 $_pageparams = ''

Detailed Description

Definition at line 1215 of file formslib.php.


Member Function Documentation

_getElNamesRecursive ( element)
Parameters:
mixed$element
Returns:
array

Definition at line 1985 of file formslib.php.

_registerCancelButton ( addfieldsname)
Parameters:
string$buttonname

Definition at line 2066 of file formslib.php.

Definition at line 1938 of file formslib.php.

accept ( &$  renderer)

Accepts a renderer

Parameters:
object$rendererHTML_QuickForm_Renderer An HTML_QuickForm_Renderer object public
Returns:
void

Reimplemented from HTML_QuickForm.

Definition at line 1379 of file formslib.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.

Parameters:
string$groupForm group name
mixed$arg1Array 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$resetClient-side: whether to reset the element's value to its original state if validation failed. public

Reimplemented from HTML_QuickForm.

Definition at line 1708 of file formslib.php.

addHelpButton ( elementname,
identifier,
component = 'moodle',
linktext = '',
suppresscheck = false 
)

Add a help button to element, only one button per element is allowed.

This is new, simplified and preferable method of setting a help icon on form elements. It uses the new $OUTPUT->help_icon().

Typically, you will provide the same identifier and the component as you have used for the label of the element. The string identifier with the _help suffix added is then used as the help string.

There has to be two strings defined: 1/ get_string($identifier, $component) - the title of the help page 2/ get_string($identifier.'_help', $component) - the actual help page text

Since:
2.0
Parameters:
string$elementnamename of the element to add the item to
string$identifierhelp string identifier without _help suffix
string$componentcomponent name to look the help string in
string$linktextoptional text to display next to the icon
boolean$suppresscheckset to true if the element may not exist
Returns:
void

Definition at line 1602 of file formslib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
string$elementForm element name
string$messageMessage to display for invalid data
string$typeRule type, use getRegisteredRules() to get types
string$format(optional)Required for extra rule data
string$validation(optional)Where to perform validation: "server", "client"
boolean$resetClient-side validation: reset the form element to its original value if there is an error?
boolean$forceForce the rule to be applied, even if the target form element does not exist public

Reimplemented from HTML_QuickForm.

Definition at line 1682 of file formslib.php.

closeHeaderBefore ( elementName)
Parameters:
string$elementName

Definition at line 1424 of file formslib.php.

disabledIf ( elementName,
dependentOn,
condition = 'notchecked',
value = '1' 
)

Adds a dependency for $elementName which will be disabled if $condition is met. If $condition = 'notchecked' (default) then the condition is that the $dependentOn element is not checked. If $condition = 'checked' then the condition is that the $dependentOn element is checked. If $condition is something else (like "eq" for equals) then it is checked to see if the value of the $dependentOn element is $condition (such as equal) to $value.

Parameters:
string$elementNamethe name of the element which will be disabled
string$dependentOnthe name of the element whose state will be checked for condition
string$conditionthe condition to check
mixed$valueused in conjunction with condition.

Definition at line 2038 of file formslib.php.

Here is the caller graph for this function:

exportValues ( elementList = null)
Parameters:
string$elementList

Reimplemented from HTML_QuickForm.

Definition at line 1629 of file formslib.php.

Here is the call graph for this function:

Returns:
string

Definition at line 1509 of file formslib.php.

Definition at line 1953 of file formslib.php.

Returns:
string

Definition at line 1502 of file formslib.php.

Definition at line 1367 of file formslib.php.

Returns the client side validation script

The code here was copied from HTML_QuickForm_DHTMLRulesTableless who copied it from HTML_QuickForm and slightly modified to run rules per-element Needed to override this because of an error with client side validation of grouped elements.

public

Returns:
string Javascript to perform validation, empty string if no 'client' rules were added

Reimplemented from HTML_QuickForm_DHTMLRulesTableless.

Definition at line 1740 of file formslib.php.

Here is the call graph for this function:

hardFreeze ( elementList = null)

Displays elements without HTML input tags. This method is different to freeze() in that it makes sure no hidden elements are included in the form. Note: If you want to make sure the submitted value is ignored, please use setDefaults().

This function also removes all previously defined rules.

Parameters:
mixed$elementListarray or string of element(s) to be frozen public

Definition at line 2080 of file formslib.php.

Here is the caller graph for this function:

hardFreezeAllVisibleExcept ( elementList)

Hard freeze all elements in a form except those whose names are in $elementList or hidden elements in a form.

This function also removes all previously defined rules of elements it freezes.

throws HTML_QuickForm_Error

Parameters:
array$elementListarray or string of element(s) not to be frozen public

Definition at line 2124 of file formslib.php.

isNoSubmitButton ( buttonname)
Parameters:
string$buttonname
Returns:
mixed

Definition at line 2059 of file formslib.php.

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

Returns:
bool

Reimplemented from HTML_QuickForm.

Definition at line 2157 of file formslib.php.

MoodleQuickForm ( formName,
method,
action,
target = '',
attributes = null 
)

Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless

object int $formcounter

Parameters:
string$formNameForm's name.
string$method(optional)Form's method defaults to 'POST'
mixed$action(optional)Form's action - string or moodle_url
string$target(optional)Form's target defaults to none
mixed$attributes(optional)Extra attributes for <form> tag public

Definition at line 1274 of file formslib.php.

Here is the call graph for this function:

registerNoSubmitButton ( buttonname)

Definition at line 2051 of file formslib.php.

setAdvanced ( elementName,
advanced = true 
)

Use this method to indicate an element in a form is an advanced field. If items in a form are marked as advanced then 'Hide/Show Advanced' buttons will automatically be displayed in the form so the user can decide whether to display advanced form controls.

If you set a header element to advanced then all elements it contains will also be set as advanced.

Parameters:
string$elementNamegroup or element name (not the element name of something inside a group).
boolean$advanceddefault true sets the element to advanced. False removes advanced mark.

Definition at line 1316 of file formslib.php.

Here is the caller graph for this function:

setConstant ( elname,
value 
)

Set constant value not overridden by _POST or _GET note: this does not work for complex names with [] :-(

Parameters:
string$elnamename of element
mixed$value
Returns:
void

Definition at line 1620 of file formslib.php.

Here is the call graph for this function:

setDefault ( elementName,
defaultValue 
)

Initializes a default form value. Used to specify the default for a new entry where no data is loaded in using moodleform::set_data()

note: $slashed param removed

Parameters:
string$elementnameelement name
mixed$valuesvalues for that element name public
Returns:
void

Definition at line 1524 of file formslib.php.

Here is the caller graph for this function:

setHelpButton ( elementname,
buttonargs,
suppresscheck = false,
function = 'helpbutton' 
)

Add a single button.

Deprecated:
use addHelpButton() instead
Parameters:
string$elementnamename of the element to add the item to
array$buttonarguments to pass to function $function
boolean$suppresscheckwhether to throw an error if the element doesn't exist.
string$function- function to generate html from the arguments in $button
string$function

Definition at line 1554 of file formslib.php.

Here is the call graph for this function:

setHelpButtons ( buttons,
suppresscheck = false,
function = 'helpbutton' 
)

Add an array of buttons to the form

Parameters:
array$buttonsAn associative array representing help button to attach to to the form. keys of array correspond to names of elements in form.
Deprecated:
since Moodle 2.0 - use addHelpButton() call on each element manually
Parameters:
bool$suppresscheck
string$functionpublic

Definition at line 1536 of file formslib.php.

Here is the call graph for this function:

setShowAdvanced ( showadvancedNow = null)

Set whether to show advanced elements in the form on first displaying form. Default is not to display advanced elements in the form until 'Show Advanced' is pressed.

You can get the last state of the form and possibly save it for this user by using value 'mform_showadvanced_last' in submitted data.

Parameters:
boolean$showadvancedNow

Definition at line 1339 of file formslib.php.

Here is the call graph for this function:

setType ( elementname,
paramtype 
)

Should be used for all elements of a form except for select, radio and checkboxes which clean their own data.

Parameters:
string$elementname
integer$paramtypeuse the constants PARAM_*. * PARAM_CLEAN is deprecated and you should try to use a more specific type. * PARAM_TEXT should be used for cleaning data that is expected to be plain text. It will strip all html tags. But will still let tags for multilang support through. * PARAM_RAW means no cleaning whatsoever, it is used mostly for data from the html editor. Data from the editor is later cleaned before display using format_text() function. PARAM_RAW can also be used for data that is validated by some other way or printed by p() or s(). * PARAM_INT should be used for integers. * PARAM_ACTION is an alias of PARAM_ALPHA and is used for hidden fields specifying form actions.

Definition at line 1447 of file formslib.php.

setTypes ( paramtypes)

See description of setType above. This can be used to set several types at once.

Parameters:
array$paramtypes

Definition at line 1456 of file formslib.php.

updateSubmission ( submission,
files 
)
Parameters:
array$submission
array$files

Definition at line 1464 of file formslib.php.

Here is the call graph for this function:


Field Documentation

$_advancedElements = array()

Definition at line 1237 of file formslib.php.

$_cancelButtons = array()

Definition at line 1230 of file formslib.php.

$_dependencies = array()

Definition at line 1218 of file formslib.php.

$_formName = ''

Definition at line 1253 of file formslib.php.

$_noSubmitButtons = array()

Definition at line 1224 of file formslib.php.

$_pageparams = ''

Definition at line 1260 of file formslib.php.

$_showAdvanced = null

Definition at line 1244 of file formslib.php.

$_types = array()

Definition at line 1217 of file formslib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations