Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

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,
return: void

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.

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

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

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

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.

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

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

return: void

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

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

_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

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

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

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

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

param: string
return: string