{"action":"closed","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/19016","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/19016/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/19016/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/19016/events","html_url":"https://github.com/symfony/symfony/issues/19016","id":159553248,"number":19016,"title":"[Form] Choice attr is applied to each <option />","user":{"login":"alanhartless","id":63312,"avatar_url":"https://avatars.githubusercontent.com/u/63312?v=3","gravatar_id":"","url":"https://api.github.com/users/alanhartless","html_url":"https://github.com/alanhartless","followers_url":"https://api.github.com/users/alanhartless/followers","following_url":"https://api.github.com/users/alanhartless/following{/other_user}","gists_url":"https://api.github.com/users/alanhartless/gists{/gist_id}","starred_url":"https://api.github.com/users/alanhartless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alanhartless/subscriptions","organizations_url":"https://api.github.com/users/alanhartless/orgs","repos_url":"https://api.github.com/users/alanhartless/repos","events_url":"https://api.github.com/users/alanhartless/events{/privacy}","received_events_url":"https://api.github.com/users/alanhartless/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/symfony/symfony/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Form","name":"Form","color":"DDDDDD"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Needs%20Review","name":"Status: Needs Review","color":"ededed"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Unconfirmed","name":"Unconfirmed","color":"444444"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-10T03:39:50Z","updated_at":"2016-06-13T05:30:18Z","closed_at":"2016-06-13T05:30:18Z","body":"Just upgraded to Symfony 2.7 from 2.5 and noticed that choice field attributes are getting applied to each options in PHP form templates. When I remove the call to the attributes block in the following line, the option attributes are not generated. \r\n\r\nhttps://github.com/symfony/framework-bundle/blob/master/Resources/views/Form/choice_widget_options.html.php#L11\r\n\r\nFor example,\r\n\r\n```\r\n            $builder->add(\r\n                'source',\r\n                'choice',\r\n                [\r\n                    'choices'     => $choices,\r\n                    'expanded'    => false,\r\n                    'multiple'    => false,\r\n                    'label'       => 'do_something,\r\n                    'label_attr'  => ['class' => 'control-label'],\r\n                    'empty_value' => false,\r\n                    'required'    => false,\r\n                    'attr'        => [\r\n                        'class'    => 'form-control',\r\n                        'onchange' => 'doSomething();'\r\n                    ]\r\n                ]\r\n            );\r\n```\r\n\r\nWill result in something like \r\n```\r\n<select class='form-control' onchange='doSomething();'>\r\n    <option class='form-control' onchange='doSomething();' value=''>Foo</option>\r\n    <option class='form-control' onchange='doSomething();' value=''>Bar</option>\r\n</select>\r\n```\r\n\r\nIs this intentional and if so, is there a recommended way to not do this (even if I set `choice_attr => []`, it seems to be populating the option attributes with the select's attributes). Or is this a bug?"}}
{"actor":{"display_login":"fabpot"}}