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 402] [Versions 400 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

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

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

return: void
param: array  Array representation of an element

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

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