MDL-19756 Added shortcut to html_select_option to make checkboxes
This commit is contained in:
@@ -4184,6 +4184,24 @@ class html_select_option extends moodle_html_component {
|
||||
|
||||
parent::prepare();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for making a checkbox-ready option
|
||||
* @param string $value The value of the checkbox
|
||||
* @param boolean $checked
|
||||
* @param string $label
|
||||
* @param string $alt
|
||||
* @return html_select_option A component ready for $OUTPUT->checkbox()
|
||||
*/
|
||||
public function make_checkbox($value, $checked, $label='', $alt='') {
|
||||
$checkbox = new html_select_option();
|
||||
$checkbox->value = $value;
|
||||
$checkbox->selected = $checked;
|
||||
$checkbox->text = $label;
|
||||
$checkbox->label->text = $label;
|
||||
$checkbox->alt = $alt;
|
||||
return $checkbox;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user