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.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Static utility methods.

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

Defines 2 classes

HTML_QuickForm_element:: (2 methods):
  __construct()
  HTML_QuickForm_element()

name:: (20 methods):
  apiVersion()
  getType()
  setName()
  getName()
  setValue()
  getValue()
  freeze()
  unfreeze()
  getFrozenHtml()
  _getPersistantData()
  isFrozen()
  setPersistantFreeze()
  setLabel()
  getLabel()
  _findValue()
  onQuickFormEvent()
  accept()
  _generateId()
  exportValue()
  _prepareValue()


Class: HTML_QuickForm_element  - X-Ref

Base class for form elements

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

return: void
param: string     Name of the element
param: mixed      Label(s) for the element
param: mixed      Associative array of tag attributes or HTML attributes name="value" pairs

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


Class: name  - X-Ref

apiVersion()   X-Ref
Returns the current API version

return: float

getType()   X-Ref
Returns element type

return: string

setName($name)   X-Ref
Sets the input field name

return: void
param: string    $name   Input field name attribute

getName()   X-Ref
Returns the element name

return: string

setValue($value)   X-Ref
Sets the value of the form element

return: void
param: string    $value      Default value of the form element

getValue()   X-Ref
Returns the value of the form element

return: mixed

freeze()   X-Ref
Freeze the element so that only its value is returned

return: void

unfreeze()   X-Ref
Unfreezes the element so that it becomes editable

return: void

getFrozenHtml()   X-Ref
Returns the value of field without HTML tags

return: string

_getPersistantData()   X-Ref
Used by getFrozenHtml() to pass the element's value if _persistantFreeze is on

return: string

isFrozen()   X-Ref
Returns whether or not the element is frozen

return: bool

setPersistantFreeze($persistant=false)   X-Ref
Sets wether an element value should be kept in an hidden field
when the element is frozen or not

return: void
param: bool    $persistant   True if persistant value

setLabel($label)   X-Ref
Sets display text for the element

return: void
param: string    $label  Display text for the element

getLabel()   X-Ref
Returns display text for the element

return: string

_findValue(&$values)   X-Ref
Tries to find the element value from the values array

return: mixed

onQuickFormEvent($event, $arg, &$caller)   X-Ref
Called by HTML_QuickForm whenever form event is made on this element

return: void
param: string    $event  Name of event
param: mixed     $arg    event arguments
param: object    $caller calling object

accept(&$renderer, $required=false, $error=null)   X-Ref
Accepts a renderer

return: void
param: object     An HTML_QuickForm_Renderer object
param: bool       Whether an element is required
param: string     An error message associated with an element

_generateId()   X-Ref
Automatically generates and assigns an 'id' attribute for the element.

Currently used to ensure that labels work on radio buttons and
checkboxes. Per idea of Alexander Radivanovich.

return: void

exportValue(&$submitValues, $assoc = false)   X-Ref
Returns a 'safe' element's value

return: mixed
param: array   array of submitted values to search
param: bool    whether to return the value as associative array

_prepareValue($value, $assoc)   X-Ref
Used by exportValue() to prepare the value for returning

return: mixed
param: mixed   the value found in exportValue()
param: bool    whether to return the value as associative array