symfony/symfony — pull request #10296 by guilhermeblanco (2014-02-20 04:11:16+00:00)
Title: [Form] Fix double attributes rendering on form tag

| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| License | MIT

There is a very weird issue not tracked as part of Symfony 2.4. When creating a form and consuming it using TwigEngine, for the given piece of twig template:

```html
{{ form(my_form, {
'method': 'POST',
'action': '/process',
'attr': {
'data-name': 'test',
'class': 'form'
}
}) }}
```

It does generate this HTML:

```html

Email

```

As you may see, it duplicates the attributes of form inside of a div which is the direct child of the form start.
Tracking down the issue, form calls form_start, which renders the form tag. After that, it calls form_widget which makes an initial decision of calling form_widget_compound, creating the div tag with all form attributes.
This patch proposes a fix to not create this initial div tag if form has no parent (root element), properly addressing the issue of duplicated classes (and other items).

This issue affects master and 2.4 from what I've seen.