|
bool | $allowempty = null |
| if the selected value can be empty.
|
|
string | $description = null |
| the choice description.
|
|
object[] | $options = [] |
| The user choices.
|
|
string | $selected = null |
| the selected option.
|
|
◆ __construct()
core\output\choicelist::__construct |
( |
?string | $description = null | ) |
|
Constructor.
- Parameters
-
string | $description | the choice description. |
◆ add_option()
core\output\choicelist::add_option |
( |
string | $value, |
|
|
string | $name, |
|
|
array | $definition = [] ) |
Add option to the user choice.
The definition object could contain the following keys:
- string description: the description of the option.
- moodle_url url: the URL to link to.
- pix_icon icon: the icon to display.
- bool disabled: whether the option is disabled.
- bool selected: whether the option is selected.
- array extras: an array of HTML attributes to add to the option (attribute => value).
- Parameters
-
string | $value | |
string | $name | |
array | $definition | an optional array of definition for the option. |
◆ add_option_extras()
core\output\choicelist::add_option_extras |
( |
string | $value, |
|
|
array | $extras ) |
Add HTML attributes to the option.
- Parameters
-
string | $value | The value of the option. |
array | $extras | an array to add HTML attributes to the option (attribute => value). |
◆ count_options()
core\output\choicelist::count_options |
( |
| ) |
|
Get the number of options added to the choice list.
- Return values
-
◆ export_for_template()
core\output\choicelist::export_for_template |
( |
renderer_base | $output | ) |
|
Export for template.
- Parameters
-
- Return values
-
Implements templatable.
◆ get_allow_empty()
core\output\choicelist::get_allow_empty |
( |
| ) |
|
Get the allow empty option.
- Return values
-
bool | Whether the selected value can be empty. |
◆ get_description()
core\output\choicelist::get_description |
( |
| ) |
|
Get the choice description option.
- Return values
-
string|null | the current description. |
◆ get_option_extras()
core\output\choicelist::get_option_extras |
( |
string | $value | ) |
|
Retrieves the HTML attributes for a given value from the options array.
- Parameters
-
string | $value | The value for which to retrieve the extras. |
- Return values
-
array | an array of HTML attributes of the option (attribute => value). |
◆ get_selectable_options()
core\output\choicelist::get_selectable_options |
( |
| ) |
|
Get the selectable options.
This method returns an array of options that are selectable, excluding the selected option and any disabled options.
- Return values
-
◆ get_selected_content()
core\output\choicelist::get_selected_content |
( |
renderer_base | $output | ) |
|
Get the selected option HTML.
This method is used to display the selected option and the option icon.
- Parameters
-
- Return values
-
◆ get_selected_value()
core\output\choicelist::get_selected_value |
( |
| ) |
|
Get the selected option.
- Return values
-
string|null | The value of the selected option. |
◆ get_template_name() [1/2]
core\output\choicelist::get_template_name |
( |
renderer_base | $renderer | ) |
|
Get the name of the template to use for this templatable.
- Parameters
-
- Return values
-
◆ get_template_name() [2/2]
core\output\named_templatable::get_template_name |
( |
\renderer_base | $renderer | ) |
|
|
inherited |
◆ has_value()
core\output\choicelist::has_value |
( |
string | $value | ) |
|
Check if the value is in the options.
- Parameters
-
string | $value | The value to check. |
- Return values
-
◆ set_allow_empty()
core\output\choicelist::set_allow_empty |
( |
bool | $allowempty | ) |
|
Set the allow empty option.
- Parameters
-
bool | $allowempty | Whether the selected value can be empty. |
◆ set_description()
core\output\choicelist::set_description |
( |
string | $value | ) |
|
Set the general choice description option.
- Parameters
-
string | $value | the new description. |
◆ set_option_disabled()
core\output\choicelist::set_option_disabled |
( |
string | $value, |
|
|
bool | $disabled ) |
Set the option disabled.
- Parameters
-
string | $value | The value of the option. |
bool | $disabled | Whether the option is disabled. |
◆ set_option_extras()
core\output\choicelist::set_option_extras |
( |
string | $value, |
|
|
array | $extras ) |
Sets the HTML attributes to the option.
This method will remove any previous extra attributes.
- Parameters
-
string | $value | The value of the option. |
array | $extras | an array to add HTML attributes to the option (attribute => value). |
◆ set_selected_value()
core\output\choicelist::set_selected_value |
( |
string | $value | ) |
|
Set the selected option.
- Parameters
-
string | $value | The value of the selected option. |
The documentation for this class was generated from the following file:
- lib/classes/output/choicelist.php