Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 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

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

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

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

getName()   X-Ref
Returns the element name

return: string

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

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

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

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

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

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

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

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

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

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

_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

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

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

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