mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
Merge branch 'MDL-65523-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
465ed6f107
1 changed files with 5 additions and 2 deletions
|
@ -55,10 +55,13 @@ class data_controller extends \core_customfield\data_controller {
|
||||||
$field = $this->get_field();
|
$field = $this->get_field();
|
||||||
$config = $field->get('configdata');
|
$config = $field->get('configdata');
|
||||||
$elementname = $this->get_form_element_name();
|
$elementname = $this->get_form_element_name();
|
||||||
$mform->addElement('advcheckbox', $elementname, $this->get_field()->get_formatted_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.
|
||||||
|
$isrequired = $field->get_configdata_property('required');
|
||||||
|
$mform->addElement($isrequired ? 'checkbox' : 'advcheckbox', $elementname, $this->get_field()->get_formatted_name());
|
||||||
$mform->setDefault($elementname, $config['checkbydefault']);
|
$mform->setDefault($elementname, $config['checkbydefault']);
|
||||||
$mform->setType($elementname, PARAM_BOOL);
|
$mform->setType($elementname, PARAM_BOOL);
|
||||||
if ($field->get_configdata_property('required')) {
|
if ($isrequired) {
|
||||||
$mform->addRule($elementname, null, 'required', null, 'client');
|
$mform->addRule($elementname, null, 'required', null, 'client');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue