Cannot display help for element within a group

Cannot display help for element within a group

von Joseph Rézeau -
Anzahl Antworten: 1
Nutzerbild von Core developers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Plugin developers Nutzerbild von Testers Nutzerbild von Translators

Here is a sample extract from my form

1 $mychoices = array(0,1,2,3,4);
2 $mygroup = [];
3 $mygroup[] = $mform->createElement('select', 'myelement0', 'label myelement0', array(0,1,2,3,4));
4 $mygroup[] = $mform->createElement('advcheckbox', 'myelement1', 'label myelement1');
5 $mform->addGroup($mygroup, 'mygroup');
6 $mform->addHelpButton('mygroup', 'help');
7 $mform->addHelpButton('mygroup[myelement1]', 'help');
8 $mform->hideIf('mygroup[myelement1]', 'mygroup[myelement0]', 'neq', 0);

And the result:

It all works as expected, except for the $mform->addHelpButton('mygroup[myelement1]', 'help') which throws an error:

"Trying to add help buttons to non-existent form elements : mygroup[myelement1]"

What does not look logical is that the form element mygroup[myelement1] is indeed recognized in the hideIf instruction (line 8) but considered as "non-existent" in the addHelpButton (line 7).

Any ideas? Is this a bug in the forms API?

Als Antwort auf Joseph Rézeau

Re: Cannot display help for element within a group

von Tim Hunt -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers

You can only add help icons on the group, not individual settings within the group.

Qtype_stack has some very complex groups, but once we realised this rule, we were able to work with it, and write help text for the group as a whole. Since the settings are usually related, it actually worked quite well in the end.