Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug] [Form] 2.7 - Form collection prototype required option #15544

Copy link
Copy link
Closed
@jeremywaguet

Description

@jeremywaguet
Issue body actions

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
  )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.