Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
/lib/form/ -> group.php (source)

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 402 and 403]

Form element group Contains HTML class for group form element

Copyright: 2007 Jamie Pratt <me@jamiep.org>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 288 lines (10 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 1 file
 lib/form/templatable_form_element.php

Defines 2 classes

MoodleQuickForm_group:: (2 methods):
  __construct()
  MoodleQuickForm_group()

name:: (10 methods):
  getHelpButton()
  getElementTemplateType()
  setElements()
  setMoodleForm()
  onQuickFormEvent()
  createFormElement()
  getAttributesForFormElement()
  export_for_template()
  accept()
  validateSubmitValue()


Class: MoodleQuickForm_group  - X-Ref

HTML class for a form element group

Overloaded {@link HTML_QuickForm_group} with default behavior modified for Moodle.

__construct($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true)   X-Ref
constructor

param: string $elementName (optional) name of the group
param: string $elementLabel (optional) group label
param: array $elements (optional) array of HTML_QuickForm_element elements to group
param: string $separator (optional) string to seperate elements.
param: string $appendName (optional) string to appened to grouped elements.

MoodleQuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

getHelpButton()   X-Ref
set html for help button


getElementTemplateType()   X-Ref
Returns element template, nodisplay/static/fieldset

return: string

setElements($elements)   X-Ref
Sets the grouped elements and hides label

param: array $elements

setMoodleForm($mform)   X-Ref
Stores the form this element was added to
This object is later used by {@link MoodleQuickForm_group::createElement()}

param: null|MoodleQuickForm $mform

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

If this function is overridden and parent is not called the element must be responsible for
storing the MoodleQuickForm object, see {@link MoodleQuickForm_group::setMoodleForm()}

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

createFormElement()   X-Ref
Creates an element to add to the group
Expects the same arguments as MoodleQuickForm::createElement()


getAttributesForFormElement()   X-Ref
Return attributes suitable for passing to {@see createFormElement}, comprised of all group attributes without ID in
order to ensure uniqueness of that value within the group

return: array

export_for_template(renderer_base $output)   X-Ref
No description

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

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

validateSubmitValue($values)   X-Ref
Calls the validateSubmitValue function for the containing elements and returns an error string as soon as it finds one.

param: array $values Values of the containing elements.
return: string|null Validation error message or null.