MDL-20204 migrated checkbox to html_writer

This commit is contained in:
Petr Skoda 2010-02-11 10:22:22 +00:00
parent 4461cc604d
commit 7de131039a
3 changed files with 3 additions and 41 deletions

View File

@ -158,8 +158,7 @@ if (!isset($frm->acceptechecktypes)) {
echo("</ul>"); echo("</ul>");
} }
elseif ($key == AN_METHOD_ECHECK) { elseif ($key == AN_METHOD_ECHECK) {
$checkbox = html_writer::checkbox('enrol_authorize', AN_METHOD_ECHECK, in_array(AN_METHOD_ECHECK, $paymentmethodsenabled), get_string('method'.AN_METHOD_ECHECK)); echo html_writer::checkbox('acceptmethods[]', AN_METHOD_ECHECK, in_array(AN_METHOD_ECHECK, $paymentmethodsenabled), get_string('method'.AN_METHOD_ECHECK, 'enrol_authorize'));
echo $OUTPUT->checkbox($checkbox, 'acceptmethods[]');
echo("<ul>"); // blockquote breaks <span> and <br> tags echo("<ul>"); // blockquote breaks <span> and <br> tags
$echecktypesenabled = get_list_of_bank_account_types(); $echecktypesenabled = get_list_of_bank_account_types();
$allechecktypes = get_list_of_bank_account_types(true); $allechecktypes = get_list_of_bank_account_types(true);

View File

@ -3374,11 +3374,11 @@ function choose_from_radio ($options, $name, $checked='', $return=false) {
*/ */
function print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script='', $return=false) { function print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script='', $return=false) {
// debugging('print_checkbox() has been deprecated. Please change your code to use $OUTPUT->checkbox($checkbox).'); // debugging('print_checkbox() has been deprecated. Please change your code to use html_writer::checkbox().');
global $OUTPUT; global $OUTPUT;
if (!empty($script)) { if (!empty($script)) {
debugging('The use of the $script param in print_checkbox has not been migrated into $OUTPUT->checkbox. Please use $checkbox->add_action().', DEBUG_DEVELOPER); debugging('The use of the $script param in print_checkbox has not been migrated into html_writer::checkbox().', DEBUG_DEVELOPER);
} }
$output = html_writer::checkbox($name, $value, $checked, $label); $output = html_writer::checkbox($name, $value, $checked, $label);

View File

@ -1772,43 +1772,6 @@ class core_renderer extends renderer_base {
return $this->container($this->render($button), 'closewindow'); return $this->container($this->render($button), 'closewindow');
} }
/**
* Outputs a <input type="checkbox" /> element. Optgroups are ignored, so do not
* pass a html_select_optgroup as a param to this function.
*
* @param html_select_option $option a html_select_option
* @return string the HTML for the <input type="checkbox">
*/
public function checkbox($option, $name='unnamed') {
if ($option instanceof html_select_optgroup) {
throw new coding_exception('$OUTPUT->checkbox($option) does not support a html_select_optgroup object as param.');
} else if (!($option instanceof html_select_option)) {
throw new coding_exception('$OUTPUT->checkbox($option) only accepts a html_select_option object as param.');
}
$option = clone($option);
$option->prepare($this, $this->page, $this->target);
$option->label->for = $option->id;
$this->prepare_event_handlers($option);
$output = html_writer::start_tag('span', array('class' => "checkbox $name")) . "\n";
$output .= html_writer::empty_tag('input', array(
'type' => 'checkbox',
'value' => $option->value,
'name' => $name,
'id' => $option->id,
'alt' => $option->alt,
'disabled' => $option->disabled ? 'disabled' : null,
'class' => $option->get_classes_string(),
'checked' => $option->selected ? 'selected' : null));
$output .= $this->label($option->label);
$output .= html_writer::end_tag('span');
return $output;
}
/** /**
* Output an <option> or <optgroup> element. If an optgroup element is detected, * Output an <option> or <optgroup> element. If an optgroup element is detected,
* this will recursively output its options as well. * this will recursively output its options as well.