Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is 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