debugging('The use of the $script param in print_checkbox has not been migrated into $OUTPUT->checkbox. Please use $checkbox->add_action().', DEBUG_DEVELOPER);
}
- $checkbox = new html_select_option();
- $checkbox->value = $value;
- $checkbox->selected = $checked;
- $checkbox->text = $label;
- $checkbox->label->text = $label;
- $checkbox->alt = $alt;
-
- $output = $OUTPUT->checkbox($checkbox, $name);
+ $output = $OUTPUT->checkbox(html_select_option::make_checkbox($value, $checked, $label, $alt), $name);
if (empty($return)) {
echo $output;
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;
+ }
}
/**