Cannot display help for element within a group

Cannot display help for element within a group

eftir Joseph Rézeau -
Number of replies: 1
Mynd av Core developers Mynd av Particularly helpful Moodlers Mynd av Plugin developers Mynd av Testers Mynd av 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?

Average of ratings: -
In reply to Joseph Rézeau

Re: Cannot display help for element within a group

eftir Tim Hunt -
Mynd av Core developers Mynd av Documentation writers Mynd av Particularly helpful Moodlers Mynd av Peer reviewers Mynd av 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.