I have tried following the advice for using checkbox controllers in Moodle in a moodle_form. However, the setDefault() function doesn't seem to work as expected. I am able to set default values without using the checkbox controller; when I add the latter, the original value (which sets all of the member checkboxes to checked or unchecked) seems to override anything I attempt set as the default later on.
Here is the relevant code:
foreach ($groups as $group) {
$elname = 'linkedgroups[' . $group->id . ']';
$mform->addElement('advcheckbox', $elname, $group->name, null, array('group' => 2));
}
$this->add_checkbox_controller(2, null, array('style' => 'font-weight: bold;'), 0);
foreach ($groupsassignedids as $groupid) {
$mform->setDefault('linkedgroups['. $groupid . ']', 1);
}
Aucun commentaire:
Enregistrer un commentaire