Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
MoodleQuickForm_choicedropdown Class Reference
Inheritance diagram for MoodleQuickForm_choicedropdown:
templatable

Public Member Functions

 __construct ( $elementname=null, $elementlabel=null, choicelist $options=null, $attributes=null)
 Constructor.
 
 export_for_template (renderer_base $output)
 Function to export the renderer data in a format that is suitable for a mustache template.
 
 exportValue (&$submitvalues, $assoc=false)
 We check the options and return only the values that could have been selected.
 
 getElementTemplateType ()
 Slightly different container template when frozen.
 
 getHelpButton ()
 get html for help button
 
 load (&$choice, $value=null, $unused2=null, $unused3=null, $unused4=null)
 Loads options from a choicelist.
 
 set_dialog_width (string $width)
 Set the dropdown width.
 
 setHiddenLabel ($hiddenLabel)
 Sets label to be hidden.
 
 toHtml ()
 Returns HTML for select form element.
 

Public Attributes

string[] const WIDTH = status::WIDTH
 Dropdown dialog width.
 

Protected Attributes

string string $_helpbutton = ''
 html for help button, if empty then no help.
 
bool bool $_hiddenLabel = false
 if true label will be hidden.
 
choicelist choicelist $choice = null
 the user choices.
 
string string $dropdownwidth = status::WIDTH['small']
 the dropdown width (from core\output\local\dropdown\status\WIDTH).
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

MoodleQuickForm_choicedropdown::__construct ( $elementname = null,
$elementlabel = null,
choicelist $options = null,
$attributes = null )

Constructor.

Parameters
string$elementnameSelect name attribute
mixed$elementlabelLabel(s) for the select
choicelist$optionsData to be used to populate options
mixed$attributesEither a typical HTML attribute string or an associative array

Member Function Documentation

◆ export_for_template()

MoodleQuickForm_choicedropdown::export_for_template ( renderer_base $output)

Function to export the renderer data in a format that is suitable for a mustache template.

This means:

  1. No complex types - only stdClass, array, int, string, float, bool
  2. Any additional info that is required for the template is pre-calculated (e.g. capability checks).
Parameters
renderer_base$outputUsed to do a final render of any components that need to be rendered for export.
Return values
stdClass|array

Implements templatable.

◆ exportValue()

MoodleQuickForm_choicedropdown::exportValue ( & $submitvalues,
$assoc = false )

We check the options and return only the values that could have been selected.

We also return a scalar value if select is not "multiple"

Parameters
string$submitvaluessubmitted values
bool$associf true the returned value is associated array
Return values
string|null

◆ getElementTemplateType()

MoodleQuickForm_choicedropdown::getElementTemplateType ( )

Slightly different container template when frozen.

Don't want to use a label tag with a for attribute in that case for the element label but instead use a div. Templates are defined in renderer constructor.

Return values
string

◆ getHelpButton()

MoodleQuickForm_choicedropdown::getHelpButton ( )

get html for help button

Return values
stringhtml for help button

◆ load()

MoodleQuickForm_choicedropdown::load ( & $choice,
$value = null,
$unused2 = null,
$unused3 = null,
$unused4 = null )

Loads options from a choicelist.

Parameters
choicelist$choiceOptions source currently supports assoc array or DB_result
string | null$valueoptional value (in case it is not defined in the choicelist)
string | null$unused2unused
string | null$unused3unused
string | null$unused4unused
Return values
bool

◆ set_dialog_width()

MoodleQuickForm_choicedropdown::set_dialog_width ( string $width)

Set the dropdown width.

Parameters
string$width

◆ setHiddenLabel()

MoodleQuickForm_choicedropdown::setHiddenLabel ( $hiddenLabel)

Sets label to be hidden.

Parameters
bool$hiddenLabelsets if label should be hidden

◆ toHtml()

MoodleQuickForm_choicedropdown::toHtml ( )

Returns HTML for select form element.

This method is only needed when forms renderer is forces via $GLOBALS['_HTML_QuickForm_default_renderer']. Otherwise the renderer will use mustache templates.

Return values
string

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