Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
MoodleQuickForm_questioncategory Class Reference

Drop down for question categories. More...

Inheritance diagram for MoodleQuickForm_questioncategory:
MoodleQuickForm_selectgroups templatable

Public Member Functions

 __construct ($elementName=null, $elementLabel=null, $options=null, $attributes=null)
 Constructor.
 
 addOptGroup ($text, $value, $attributes=null)
 Adds a new OPTION to the SELECT.
 
 addOption ($optgroup, $text, $value, $attributes=null)
 Adds a new OPTION to an optgroup.
 
 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.
 
 getFrozenHtml ()
 Returns the value of field without HTML tags.
 
 getHelpButton ()
 get html for help button
 
 getMultiple ()
 Returns the select mutiple attribute.
 
 getName ()
 Returns the element name.
 
 getPrivateName ()
 Returns the element name (possibly with brackets appended)
 
 getSelected ()
 Returns an array of the selected values.
 
 getSize ()
 Returns the select field size.
 
 getValue ()
 Returns an array of the selected values.
 
 loadArrayOptGroups ($arr, $values=null)
 Loads the options from an associative array.
 
 loadArrayOptions ($optgroup, $arr, $values=null)
 Loads the options from an associative array.
 
 MoodleQuickForm_questioncategory ($elementName=null, $elementLabel=null, $options=null, $attributes=null)
 Old syntax of class constructor.
 
 MoodleQuickForm_selectgroups ($elementName=null, $elementLabel=null, $optgrps=null, $attributes=null, $showchoose=false)
 Old syntax of class constructor.
 
 onQuickFormEvent ($event, $arg, &$caller)
 Called by HTML_QuickForm whenever form event is made on this element.
 
 setHiddenLabel ($hiddenLabel)
 Sets label to be hidden.
 
 setMultiple ($multiple)
 Sets the select mutiple attribute.
 
 setName ($name)
 Sets the input field name.
 
 setSelected ($values)
 Sets the default values of the select box.
 
 setSize ($size)
 Sets the select field size, only applies to 'multiple' selects.
 
 setValue ($value)
 Sets the value of the form element.
 
 toHtml ()
 Returns the SELECT in HTML.
 

Public Attributes

string $_helpbutton =''
 html for help button, if empty then no help
 
bool $_hiddenLabel =false
 if true label will be hidden
 
array $_optGroups = array()
 Contains the select optgroups.
 
array $_options = array('top'=>false, 'currentcat'=>0, 'nochildrenof' => -1)
 default options for question categories
 
array $_values = null
 Default values of the SELECT.
 
bool $showchoose = false
 add choose option
 

Detailed Description

Drop down for question categories.

HTML class for a drop down element to select a question category.

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$elementNameSelect name attribute
mixed$elementLabelLabel(s) for the select
array$optionsadditional options. Recognised options are courseid, published and only_editable, corresponding to the arguments of question_category_options from moodlelib.php.
mixed$attributesEither a typical HTML attribute string or an associative array

Member Function Documentation

◆ addOptGroup()

MoodleQuickForm_selectgroups::addOptGroup ( $text,
$value,
$attributes = null )
inherited

Adds a new OPTION to the SELECT.

Parameters
string$textDisplay text for the OPTION
string$valueValue for the OPTION
mixed$attributesEither a typical HTML attribute string or an associative array

◆ addOption()

MoodleQuickForm_selectgroups::addOption ( $optgroup,
$text,
$value,
$attributes = null )
inherited

Adds a new OPTION to an optgroup.

Parameters
string$optgroupname of the option group
string$textDisplay text for the OPTION
string$valueValue for the OPTION
mixed$attributesEither a typical HTML attribute string or an associative array

◆ export_for_template()

MoodleQuickForm_selectgroups::export_for_template ( renderer_base $output)
inherited

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_selectgroups::exportValue ( & $submitValues,
$assoc = false )
inherited

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
array$submitValuessubmitted values
bool$associf true the retured value is associated array
Return values
mixed

◆ getElementTemplateType()

MoodleQuickForm_selectgroups::getElementTemplateType ( )
inherited

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

◆ getFrozenHtml()

MoodleQuickForm_selectgroups::getFrozenHtml ( )
inherited

Returns the value of field without HTML tags.

Return values
string

◆ getHelpButton()

MoodleQuickForm_selectgroups::getHelpButton ( )
inherited

get html for help button

Return values
stringhtml for help button

◆ getMultiple()

MoodleQuickForm_selectgroups::getMultiple ( )
inherited

Returns the select mutiple attribute.

Return values
booltrue if multiple select, false otherwise

◆ getName()

MoodleQuickForm_selectgroups::getName ( )
inherited

Returns the element name.

Return values
string

◆ getPrivateName()

MoodleQuickForm_selectgroups::getPrivateName ( )
inherited

Returns the element name (possibly with brackets appended)

Return values
string

◆ getSelected()

MoodleQuickForm_selectgroups::getSelected ( )
inherited

Returns an array of the selected values.

Return values
arrayof selected values

◆ getSize()

MoodleQuickForm_selectgroups::getSize ( )
inherited

Returns the select field size.

Return values
int

◆ getValue()

MoodleQuickForm_selectgroups::getValue ( )
inherited

Returns an array of the selected values.

Return values
arrayof selected values

◆ loadArrayOptGroups()

MoodleQuickForm_selectgroups::loadArrayOptGroups ( $arr,
$values = null )
inherited

Loads the options from an associative array.

Parameters
array$arrAssociative array of options
mixed$values(optional) Array or comma delimited string of selected values
Return values
PEAR_Error|boolon error or true
Exceptions
PEAR_Error

◆ loadArrayOptions()

MoodleQuickForm_selectgroups::loadArrayOptions ( $optgroup,
$arr,
$values = null )
inherited

Loads the options from an associative array.

Parameters
string$optgroupname of the options group
array$arrAssociative array of options
mixed$values(optional) Array or comma delimited string of selected values
Return values
PEAR_Error|boolon error or true
Exceptions
PEAR_Error

◆ MoodleQuickForm_questioncategory()

MoodleQuickForm_questioncategory::MoodleQuickForm_questioncategory ( $elementName = null,
$elementLabel = null,
$options = null,
$attributes = null )

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated
since Moodle 3.1

◆ MoodleQuickForm_selectgroups()

MoodleQuickForm_selectgroups::MoodleQuickForm_selectgroups ( $elementName = null,
$elementLabel = null,
$optgrps = null,
$attributes = null,
$showchoose = false )
inherited

Old syntax of class constructor.

Deprecated in PHP7.

Deprecated
since Moodle 3.1

◆ onQuickFormEvent()

MoodleQuickForm_selectgroups::onQuickFormEvent ( $event,
$arg,
& $caller )
inherited

Called by HTML_QuickForm whenever form event is made on this element.

Parameters
string$eventName of event
mixed$argevent arguments
object$callercalling object
Return values
bool

◆ setHiddenLabel()

MoodleQuickForm_selectgroups::setHiddenLabel ( $hiddenLabel)
inherited

Sets label to be hidden.

Parameters
bool$hiddenLabelsets if label should be hidden

◆ setMultiple()

MoodleQuickForm_selectgroups::setMultiple ( $multiple)
inherited

Sets the select mutiple attribute.

Parameters
bool$multipleWhether the select supports multi-selections

◆ setName()

MoodleQuickForm_selectgroups::setName ( $name)
inherited

Sets the input field name.

Parameters
string$nameInput field name attribute

◆ setSelected()

MoodleQuickForm_selectgroups::setSelected ( $values)
inherited

Sets the default values of the select box.

Parameters
mixed$valuesArray or comma delimited string of selected values

◆ setSize()

MoodleQuickForm_selectgroups::setSize ( $size)
inherited

Sets the select field size, only applies to 'multiple' selects.

Parameters
int$sizeSize of select field

◆ setValue()

MoodleQuickForm_selectgroups::setValue ( $value)
inherited

Sets the value of the form element.

Parameters
mixed$valueArray or comma delimited string of selected values

◆ toHtml()

MoodleQuickForm_selectgroups::toHtml ( )
inherited

Returns the SELECT in HTML.

Return values
string

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