Closed
Description
When using the 'collection' form type with the 'required' option set to false, The rendered HTML is different between the form_widget() macro and the prototype. The macro does not output the required field contrary to the prototype field.
Form definition :
$formBuilder->add('emails', 'collection', array(
'type' => 'email',
'allow_add' => true,
'required' => false
));
Twig Template :
{% for emailField in form.emails %}
{{ form_widget(emailField) }}
{% endfor %}
HTML output :
<input name="form[emails][1]" id="form_emails_1" type="email">
<input name="form[emails][2]" id="form_emails_2" type="email">
<input name="form[emails][3]" id="form_emails_2" type="email">
data-prototype:
<input type="email" id="form_emails___name__"
name="form[emails][__name__]" required="required" class="" />
Is that, the expected result ? I would expect the prototype field not to contain 'required' as the form_widget() macro doesn't output the 'required' field
I know the 'option' parameter is supposed to do the job but as the 'required' parameter is supported, the prototype output should match the macro output.
'options' => array(
'required' => false
)