still confused on forms_lib

still confused on forms_lib

by Daniele Cordella -
Number of replies: 2
Picture of Core developers Picture of Plugin developers
I found at the row 34 of moodle19/mod/lesson/mod_form.php:
// Create a text box that can be enabled/disabled for lesson time limit
$timedgrp = array();
$timedgrp[] = &$mform->createElement('text', 'maxtime');
$timedgrp[] = &$mform->createElement('checkbox', 'timed', '', get_string('enable'));
$mform->addGroup($timedgrp, 'timedgrp', get_string('maxtime', 'lesson'), array(' '), false);
$mform->disabledIf('timedgrp', 'timed');

The group is the union a textfield and a check box.
The group name is: 'timedgrp'
I disable the group if the check box is equal to 'timed' (alias if it is checked).

What I can not understand is: why do I am still able to use the checkbox even if I disabled the group (alias if I disabled the textfield and a check box)?


My original problem was: I want to disable a group made of three radio buttons.
I wrote:

$fieldname = 'acceptation';
$elements = array();
$elements[] =& $mform->createElement('radio', $fieldname, '', get_string('waiting', 'newmodule'), 0);
$elements[] =& $mform->createElement('radio', $fieldname, '', get_string('accepted','newmodule'), 1);
$elements[] =& $mform->createElement('radio', $fieldname, '', get_string('refused', 'newmodule'), 2);
$mform->addGroup($elements, 'group_'.$fieldname, get_string('group_'.$fieldname.'_label', 'newmodule'), ' ', false);
$mform->disabledIf('group_'.$fieldname, 'extra_var', 'neq', '100');

Why doesn't it work?
Thank you in advance.
Average of ratings: -