Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 311 and 403]

(no description)

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

Defines 2 classes

HTML_QuickForm_Renderer_Array:: (2 methods):
  __construct()
  HTML_QuickForm_Renderer_Array()

name:: (10 methods):
  toArray()
  startForm()
  renderHeader()
  renderElement()
  renderHidden()
  startGroup()
  finishGroup()
  _elementToArray()
  _storeArray()
  setElementStyle()


Class: HTML_QuickForm_Renderer_Array  - X-Ref

A concrete renderer for HTML_QuickForm, makes an array of form contents

Based on old toArray() code.

The form array structure is the following:
array(
'frozen'           => 'whether the form is frozen',
'javascript'       => 'javascript for client-side validation',
'attributes'       => 'attributes for <form> tag',
'requirednote      => 'note about the required elements',
// if we set the option to collect hidden elements
'hidden'           => 'collected html of all hidden elements',
// if there were some validation errors:
'errors' => array(
'1st element name' => 'Error for the 1st element',
...
'nth element name' => 'Error for the nth element'
),
// if there are no headers in the form:
'elements' => array(
element_1,
...
element_N
)
// if there are headers in the form:
'sections' => array(
array(
'header'   => 'Header text for the first header',
'name'     => 'Header name for the first header',
'elements' => array(
element_1,
...
element_K1
)
),
...
array(
'header'   => 'Header text for the Mth header',
'name'     => 'Header name for the Mth header',
'elements' => array(
element_1,
...
element_KM
)
)
)
);

where element_i is an array of the form:
array(
'name'      => 'element name',
'value'     => 'element value',
'type'      => 'type of the element',
'frozen'    => 'whether element is frozen',
'label'     => 'label for the element',
'required'  => 'whether element is required',
'error'     => 'error associated with the element',
'style'     => 'some information about element style (e.g. for Smarty)',
// if element is not a group
'html'      => 'HTML for the element'
// if element is a group
'separator' => 'separator for group elements',
'elements'  => array(
element_1,
...
element_N
)
);

__construct($collectHidden = false, $staticLabels = false)   X-Ref
Constructor

param: bool    true: collect all hidden elements into string; false: process them as usual form elements
param: bool    true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key"

HTML_QuickForm_Renderer_Array($collectHidden = false, $staticLabels = false)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

toArray()   X-Ref
Returns the resultant array

return: array

startForm(&$form)   X-Ref
No description

renderHeader(&$header)   X-Ref
No description

renderElement(&$element, $required, $error)   X-Ref
No description

renderHidden(&$element)   X-Ref
No description

startGroup(&$group, $required, $error)   X-Ref
No description

finishGroup(&$group)   X-Ref
No description

_elementToArray(&$element, $required, $error)   X-Ref
Creates an array representing an element

param: object    An HTML_QuickForm_element object
param: bool      Whether an element is required
param: string    Error associated with the element
return: array

_storeArray($elAry)   X-Ref
Stores an array representation of an element in the form array

param: array  Array representation of an element
return: void

setElementStyle($elementName, $styleName = null)   X-Ref
Sets a style to use for element rendering

param: mixed      element name or array ('element name' => 'style name')
param: string     style name if $elementName is not an array
return: void