Closed fritzmg closed 3 years ago
\Contao\Widget::getAttributesFromDca will set the ID and the name of the form element to the same value. However, this makes it impossible to do something like this:
\Contao\Widget::getAttributesFromDca
$form = new Form('foobar', 'GET', function(Form $form) use ($request) { return null !== $request && $request->query->has('submit'); }); $form->addFormField('foo1', [ 'inputType' => 'select', 'name' => 'foo[]', 'options' => [ 'option1', 'option2', ], 'value' => $request->query->get('foo')[0], ]); $form->addFormField('foo2', [ 'inputType' => 'select', 'name' => 'foo[]', 'options' => [ 'option3', 'option4', ], 'value' => $request->query->get('foo')[1], ]);
i.e. grouped form elements with []. Without the change invalid HTML would be generated, as both selects would have the ID ctrl_foo[].
[]
ctrl_foo[]
With the proposed change the ID will be ctrl_foo1 and ctrl_foo2 while the name attribute will stay at foo[].
ctrl_foo1
ctrl_foo2
foo[]
\Contao\Widget::getAttributesFromDca
will set the ID and the name of the form element to the same value. However, this makes it impossible to do something like this:i.e. grouped form elements with
[]
. Without the change invalid HTML would be generated, as both selects would have the IDctrl_foo[]
.With the proposed change the ID will be
ctrl_foo1
andctrl_foo2
while the name attribute will stay atfoo[]
.