Discussions started by Joseph Rézeau

Picture of Développeurs Picture of Développeurs de plugins Picture of Moodleurs particulièrement utiles Picture of Testeurs Picture of Traducteurs

Bonjour à tous (et en particulier à ceux qui ne visitent pas la section Développement du forum),

Pour fêter mes 68 printemps, je vous invite à aller voir la Nouvelle interface du "Test de personnalité" du plugin Questionnaire. Tous les détails ici : https://moodle.org/mod/forum/discuss.php?d=208938#p975378.

Joseph

Average of ratings: Utile (3)
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

It seems that bug MDL-18522 has never been resolved in Moodle 2.

Using Moodle 2.4 I would like to use disabledIf on individual radio buttons inside a group but have no idea how to to make it work.

The documentation at http://docs.moodle.org/dev/lib/formslib.php_Form_Definition#addGroup does not help much.

It says:

By default, groups modify the names of elements inside them by appending a number. This is often unhelpful, for example if you want to use disabledIf on the element. To prevent this behaviour, set the last parameter to false when creating a group.

From which I infer the following: If the last parameter of addGroup() is set to true (default), then it will be possible to individually disable the group's elements by their name+appended number. I create this group:

$chartgroup = array();
$chartgroup[] =& $mform->createElement('radio', 'charttype', '', 'vbar', '0');
$chartgroup[] =& $mform->createElement('radio', 'charttype', '', 'hbar', '1');
$chartgroup[] =& $mform->createElement('radio', 'charttype', '', 'radar', '2');
$mform->addGroup($chartgroup, 'chartgroup', get_string('chart:type', 'questionnaire'), ' ');

In the output HTML I notice that my radio elements have been re-named to: id_chartgroup_charttype_0, id_chartgroup_charttype_1 and

Now, when another element 'feedbacksections' in my form takes a certain value (e.g. 0), I want the 3rd radio button in my chartgroup to be disabled. However, neither of the following works:

$mform->disabledIf('charttype_2', 'feedbacksections', 'eq', 0);

$mform->disabledIf('chartgroup_charttype_2', 'feedbacksections', 'eq', 0);

$mform->disabledIf('id_chartgroup_charttype_2', 'feedbacksections', 'eq', 0);

Any idea? Is it actually still impossible to apply disabledIf to a radio button in Moodle 2?

Joseph

Average of ratings: -