Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
select type form element More...
Public Member Functions | |
__construct ($elementName=null, $elementLabel=null, $optgrps=null, $attributes=null, $showchoose=false) | |
Class constructor. | |
addOptGroup ($text, $value, $attributes=null) | |
Adds a new OPTION to the SELECT. | |
addOption ($optgroup, $text, $value, $attributes=null) | |
Adds a new OPTION to an optgroup. | |
export_for_template (renderer_base $output) | |
Function to export the renderer data in a format that is suitable for a mustache template. | |
exportValue (&$submitValues, $assoc=false) | |
We check the options and return only the values that could have been selected. | |
getElementTemplateType () | |
Slightly different container template when frozen. | |
getFrozenHtml () | |
Returns the value of field without HTML tags. | |
getHelpButton () | |
get html for help button | |
getMultiple () | |
Returns the select mutiple attribute. | |
getName () | |
Returns the element name. | |
getPrivateName () | |
Returns the element name (possibly with brackets appended) | |
getSelected () | |
Returns an array of the selected values. | |
getSize () | |
Returns the select field size. | |
getValue () | |
Returns an array of the selected values. | |
loadArrayOptGroups ($arr, $values=null) | |
Loads the options from an associative array. | |
loadArrayOptions ($optgroup, $arr, $values=null) | |
Loads the options from an associative array. | |
MoodleQuickForm_selectgroups ($elementName=null, $elementLabel=null, $optgrps=null, $attributes=null, $showchoose=false) | |
Old syntax of class constructor. | |
onQuickFormEvent ($event, $arg, &$caller) | |
Called by HTML_QuickForm whenever form event is made on this element. | |
setHiddenLabel ($hiddenLabel) | |
Sets label to be hidden. | |
setMultiple ($multiple) | |
Sets the select mutiple attribute. | |
setName ($name) | |
Sets the input field name. | |
setSelected ($values) | |
Sets the default values of the select box. | |
setSize ($size) | |
Sets the select field size, only applies to 'multiple' selects. | |
setValue ($value) | |
Sets the value of the form element. | |
toHtml () | |
Returns the SELECT in HTML. | |
select type form element
Class to dynamically create an HTML SELECT with all options grouped in optgroups
Class to dynamically create an HTML SELECT with all options grouped in optgroups
MoodleQuickForm_selectgroups::__construct | ( | $elementName = null, | |
$elementLabel = null, | |||
$optgrps = null, | |||
$attributes = null, | |||
$showchoose = false ) |
Class constructor.
string | $elementName | Select name attribute |
mixed | $elementLabel | Label(s) for the select |
array | $optgrps | Data to be used to populate options |
mixed | $attributes | Either a typical HTML attribute string or an associative array |
bool | $showchoose | add standard moodle "Choose..." option as first item |
MoodleQuickForm_selectgroups::addOptGroup | ( | $text, | |
$value, | |||
$attributes = null ) |
Adds a new OPTION to the SELECT.
string | $text | Display text for the OPTION |
string | $value | Value for the OPTION |
mixed | $attributes | Either a typical HTML attribute string or an associative array |
MoodleQuickForm_selectgroups::addOption | ( | $optgroup, | |
$text, | |||
$value, | |||
$attributes = null ) |
Adds a new OPTION to an optgroup.
string | $optgroup | name of the option group |
string | $text | Display text for the OPTION |
string | $value | Value for the OPTION |
mixed | $attributes | Either a typical HTML attribute string or an associative array |
MoodleQuickForm_selectgroups::export_for_template | ( | renderer_base | $output | ) |
Function to export the renderer data in a format that is suitable for a mustache template.
This means:
renderer_base | $output | Used to do a final render of any components that need to be rendered for export. |
stdClass|array |
Implements templatable.
MoodleQuickForm_selectgroups::exportValue | ( | & | $submitValues, |
$assoc = false ) |
We check the options and return only the values that could have been selected.
We also return a scalar value if select is not "multiple"
array | $submitValues | submitted values |
bool | $assoc | if true the retured value is associated array |
mixed |
MoodleQuickForm_selectgroups::getElementTemplateType | ( | ) |
Slightly different container template when frozen.
Don't want to use a label tag with a for attribute in that case for the element label but instead use a div. Templates are defined in renderer constructor.
string |
MoodleQuickForm_selectgroups::getFrozenHtml | ( | ) |
Returns the value of field without HTML tags.
string |
MoodleQuickForm_selectgroups::getHelpButton | ( | ) |
get html for help button
string | html for help button |
MoodleQuickForm_selectgroups::getMultiple | ( | ) |
Returns the select mutiple attribute.
bool | true if multiple select, false otherwise |
MoodleQuickForm_selectgroups::getName | ( | ) |
Returns the element name.
string |
MoodleQuickForm_selectgroups::getPrivateName | ( | ) |
Returns the element name (possibly with brackets appended)
string |
MoodleQuickForm_selectgroups::getSelected | ( | ) |
Returns an array of the selected values.
array | of selected values |
MoodleQuickForm_selectgroups::getSize | ( | ) |
Returns the select field size.
int |
MoodleQuickForm_selectgroups::getValue | ( | ) |
Returns an array of the selected values.
array | of selected values |
MoodleQuickForm_selectgroups::loadArrayOptGroups | ( | $arr, | |
$values = null ) |
Loads the options from an associative array.
array | $arr | Associative array of options |
mixed | $values | (optional) Array or comma delimited string of selected values |
PEAR_Error|bool | on error or true |
PEAR_Error |
MoodleQuickForm_selectgroups::loadArrayOptions | ( | $optgroup, | |
$arr, | |||
$values = null ) |
Loads the options from an associative array.
string | $optgroup | name of the options group |
array | $arr | Associative array of options |
mixed | $values | (optional) Array or comma delimited string of selected values |
PEAR_Error|bool | on error or true |
PEAR_Error |
MoodleQuickForm_selectgroups::MoodleQuickForm_selectgroups | ( | $elementName = null, | |
$elementLabel = null, | |||
$optgrps = null, | |||
$attributes = null, | |||
$showchoose = false ) |
MoodleQuickForm_selectgroups::onQuickFormEvent | ( | $event, | |
$arg, | |||
& | $caller ) |
Called by HTML_QuickForm whenever form event is made on this element.
string | $event | Name of event |
mixed | $arg | event arguments |
object | $caller | calling object |
bool |
MoodleQuickForm_selectgroups::setHiddenLabel | ( | $hiddenLabel | ) |
Sets label to be hidden.
bool | $hiddenLabel | sets if label should be hidden |
MoodleQuickForm_selectgroups::setMultiple | ( | $multiple | ) |
Sets the select mutiple attribute.
bool | $multiple | Whether the select supports multi-selections |
MoodleQuickForm_selectgroups::setName | ( | $name | ) |
Sets the input field name.
string | $name | Input field name attribute |
MoodleQuickForm_selectgroups::setSelected | ( | $values | ) |
Sets the default values of the select box.
mixed | $values | Array or comma delimited string of selected values |
MoodleQuickForm_selectgroups::setSize | ( | $size | ) |
Sets the select field size, only applies to 'multiple' selects.
int | $size | Size of select field |
MoodleQuickForm_selectgroups::setValue | ( | $value | ) |
Sets the value of the form element.
mixed | $value | Array or comma delimited string of selected values |
MoodleQuickForm_selectgroups::toHtml | ( | ) |
Returns the SELECT in HTML.
string |