Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Static utility methods.

File Size: 595 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

HTML_QuickForm_hierselect:: (2 methods):
  __construct()
  HTML_QuickForm_hierselect()

name:: (21 methods):
  setOptions()
  setMainOptions()
  setSecOptions()
  _setOptions()
  setValue()
  _createElements()
  toHtml()
  _hs_findOptions()
  _hs_findSelect()
  _hs_unescapeEntities()
  _hs_replaceOptions()
  _hs_setValue()
  _hs_swapOptions()
  _hs_onReset()
  _hs_setupOnReset()
  _hs_onReload()
  accept()
  onQuickFormEvent()
  _convertArrayToJavascript()
  _convertScalarToJavascript()
  _escapeString()


Class: HTML_QuickForm_hierselect  - X-Ref

Class to dynamically create two or more HTML Select elements
The first select changes the content of the second select and so on.
This element is considered as a group. Selects will be named
groupName[0], groupName[1], groupName[2]...

__construct($elementName=null, $elementLabel=null, $attributes=null, $separator=null)   X-Ref
Class constructor

return: void
param: string    $elementName    (optional)Input field name attribute
param: string    $elementLabel   (optional)Input field label in form
param: mixed     $attributes     (optional)Either a typical HTML attribute string
param: mixed     $separator      (optional)Use a string for one separator,

HTML_QuickForm_hierselect($elementName=null, $elementLabel=null, $attributes=null, $separator=null)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

setOptions($options)   X-Ref
Initialize the array structure containing the options for each select element.
Call the functions that actually do the magic.

return: void
param: array    $options    Array of options defining each element

setMainOptions($array)   X-Ref
Sets the options for the first select element. Deprecated. setOptions() should be used.

return: void
param: array     $array    Options for the first select element

setSecOptions($array)   X-Ref
Sets the options for the second select element. Deprecated. setOptions() should be used.
The main _options array is initialized and the _setOptions function is called.

return: void
param: array     $array    Options for the second select element

_setOptions()   X-Ref
Sets the options for each select element

return: void

setValue($value)   X-Ref
Sets values for group's elements

return: void
param: array     $value    An array of 2 or more values, for the first,

_createElements()   X-Ref
Creates all the elements for the group

return: void

toHtml()   X-Ref
No description

_hs_findOptions(ary, keys)   X-Ref
No description

_hs_findSelect(form, groupName, selectIndex)   X-Ref
No description

_hs_unescapeEntities(str)   X-Ref
No description

_hs_replaceOptions(ctl, optionList)   X-Ref
No description

_hs_setValue(ctl, value)   X-Ref
No description

_hs_swapOptions(form, groupName, selectIndex)   X-Ref
No description

_hs_onReset(form, groupNames)   X-Ref
No description

_hs_setupOnReset(form, groupNames)   X-Ref
No description

_hs_onReload()   X-Ref
No description

accept(&$renderer, $required = false, $error = null)   X-Ref
No description

onQuickFormEvent($event, $arg, &$caller)   X-Ref
No description

_convertArrayToJavascript($array, $assoc = true)   X-Ref
Converts PHP array to its Javascript analog

return: string    Javascript representation of the value
param: array     PHP array to convert
param: bool      Generate Javascript object literal (default, works like PHP's associative array) or array literal

_convertScalarToJavascript($val)   X-Ref
Converts PHP's scalar value to its Javascript analog

return: string    Javascript representation of the value
param: mixed     PHP value to convert

_escapeString($str)   X-Ref
Quotes the string so that it can be used in Javascript string constants

return: string
param: string