mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-65506 forms: get the correct value for advcheckbox fields in js
This commit is contained in:
parent
f1a8db6911
commit
706c5b3acd
@ -55,8 +55,8 @@ class data_controller extends \core_customfield\data_controller {
|
||||
$field = $this->get_field();
|
||||
$config = $field->get('configdata');
|
||||
$elementname = $this->get_form_element_name();
|
||||
// TODO MDL-65506 element 'advcheckbox' does not support 'required' rule. If checkbox is required (i.e. "agree to terms")
|
||||
// then use 'checkbox' form element.
|
||||
// If checkbox is required (i.e. "agree to terms") then use 'checkbox' form element.
|
||||
// The advcheckbox element cannot be used for required fields because advcheckbox elements always provide a value.
|
||||
$isrequired = $field->get_configdata_property('required');
|
||||
$mform->addElement($isrequired ? 'checkbox' : 'advcheckbox', $elementname, $this->get_field()->get_formatted_name());
|
||||
$mform->setDefault($elementname, $config['checkbydefault']);
|
||||
|
@ -302,15 +302,13 @@ class HTML_QuickForm_RuleRegistry
|
||||
" }\n";
|
||||
}
|
||||
|
||||
} elseif ($element->getType() == 'advcheckbox') {
|
||||
$value = " value{$jsIndex} = frm.elements['$elementName'][1].checked ?" .
|
||||
" frm.elements['$elementName'][1].value : frm.elements['$elementName'][0].value;\n";
|
||||
$tmp_reset .= $reset ? " field[1].checked = field[1].defaultChecked;\n" : '';
|
||||
} elseif ($element->getType() == 'checkbox') {
|
||||
if (is_a($element, 'html_quickform_advcheckbox')) {
|
||||
$value = " value{$jsIndex} = frm.elements['$elementName'][1].checked? frm.elements['$elementName'][1].value: frm.elements['$elementName'][0].value;\n";
|
||||
$tmp_reset .= $reset ? " field[1].checked = field[1].defaultChecked;\n" : '';
|
||||
} else {
|
||||
$value = " value{$jsIndex} = frm.elements['$elementName'].checked? '1': '';\n";
|
||||
$tmp_reset .= $reset ? " field.checked = field.defaultChecked;\n" : '';
|
||||
}
|
||||
|
||||
$value = " value{$jsIndex} = frm.elements['$elementName'].checked? '1': '';\n";
|
||||
$tmp_reset .= $reset ? " field.checked = field.defaultChecked;\n" : '';
|
||||
} elseif ($element->getType() == 'radio') {
|
||||
$value = " value{$jsIndex} = '';\n" .
|
||||
// Fix for bug #5644
|
||||
|
Loading…
x
Reference in New Issue
Block a user