A generic user choice output class.  
 More...
|  | 
| string | $description = null | 
|  | the choice description. 
 | 
|  | 
| object[] | $options = [] | 
|  | The user choices. 
 | 
|  | 
| string | $selected = null | 
|  | the selected option. 
 | 
|  | 
A generic user choice output class. 
This class can be used as a generic user choice data structure for any dropdown, modal, or any other component that offers choices to the user.
- Copyright
- 2023 Ferran Recio ferra.nosp@m.n@mo.nosp@m.odle..nosp@m.com 
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 
◆ __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. |  
 
 
 
◆ 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_description()
      
        
          | core\output\choicelist::get_description | ( |  | ) |  | 
      
 
Get the choice description option. 
- Return values
- 
  
    | string|null | the current description. |  
 
 
 
◆ 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 | 
 
 
◆ 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 ) | 
      
 
Set the option disabled. 
- 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: