-
Bug
-
Resolution: Fixed
-
Minor
-
2.2
-
MOODLE_22_STABLE
-
MOODLE_22_STABLE
-
When you add a group to a form, you can choose whether the field names get messed around with. This is the last argument to addGroup. That is, if you do
$mform->addGroup(array(
|
$mform->createElement('text', 'a', 'A = '),
|
$mform->createElement('text', 'b', 'B = '),
|
), 'groupname', 'Fields', array(' '), false);
|
The two fields end up with names a and b, but if you do
$mform->addGroup(array(
|
$mform->createElement('text', 'a', 'A = '),
|
$mform->createElement('text', 'b', 'B = '),
|
), 'groupname', 'Fields', array(' '), true);
|
The two fields end up with names groupname[a] and groupname[b].
The problem comes when you try to use this in combination with repeat_elements. With $appendName = true, there is no problem. The field names become groupname[0][a], groupname[1][a], etc. The issue is with $appendName = false. Then, with the existing code, the field names are just a, b for each repeat, which means that the fields just overwrite each other.
I am about to submit a patch so that with repeat_elements and $appendName = false, the field names are a[0], a[1]. b[0], b[1], etc.