Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
MoodleQuickForm_listing Class Reference

The listing element is a simple customizable "select" without the input type=select. More...

Inheritance diagram for MoodleQuickForm_listing:

Public Member Functions

 __construct ($elementName=null, $elementLabel=null, $attributes=null, $options=array())
 Constructor.
 
 MoodleQuickForm_listing ($elementName=null, $elementLabel=null, $attributes=null, $options=array())
 Old syntax of class constructor.
 
 toHtml ()
 Returns HTML for listing form element.
 

Protected Attributes

string $hideall
 language string for Hide.
 
array $items = array()
 items to display.
 
string $showall
 language string for Show All.
 

Detailed Description

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.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

MoodleQuickForm_listing::__construct ( $elementName = null,
$elementLabel = null,
$attributes = null,
$options = array() )

Constructor.

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

Member Function Documentation

◆ MoodleQuickForm_listing()

MoodleQuickForm_listing::MoodleQuickForm_listing ( $elementName = null,
$elementLabel = null,
$attributes = null,
$options = array() )

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated
since Moodle 3.1

◆ toHtml()

MoodleQuickForm_listing::toHtml ( )

Returns HTML for listing form element.

Return values
stringthe HTML.

The documentation for this class was generated from the following file: