Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Listing form element. Contains HTML class for a listing form element.

Copyright: 2012 Jerome Mouneyrac
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 161 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

MoodleQuickForm_listing:: (2 methods):
  __construct()
  MoodleQuickForm_listing()

name:: (1 method):
  toHtml()


Class: MoodleQuickForm_listing  - X-Ref

The listing element is a simple customizable "select" without the input type=select.
One main div contains the "large" html of an item.
A show/hide div shows a hidden div containing the list of all items.
This list is composed by the "small" html of each item.

How to use it:
The options parameter is an array containing:
- items => array of object: the key is the value of the form input
$item->rowhtml => small html
$item->mainhtml => large html
- showall/hideall => string for the Show/Hide button

WARNINGS: The form lets you display HTML. So it is subject to CROSS-SCRIPTING if you send it uncleaned HTML.
Don't forget to escape your HTML as soon as one string comes from an input/external source.

How to customize it:
You can change the css in core.css. For example if you remove float:left; from .formlistingrow,
then the item list is not display as tabs but as rows.

__construct($elementName=null, $elementLabel=null, $attributes=null, $options=array()   X-Ref
Constructor.

param: string $elementName (optional) name of the listing.
param: string $elementLabel (optional) listing label.
param: array $attributes (optional) Either a typical HTML attribute string or an associative array.
param: array $options set of options to initalize listing.

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


Class: name  - X-Ref

toHtml()   X-Ref
Returns HTML for listing form element.

return: string the HTML.