{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/14393","labels_url":"https://api.github.com/repos/symfony/symfony/issues/14393/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/14393/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/14393/events","html_url":"https://github.com/symfony/symfony/issues/14393","id":69291769,"number":14393,"title":"[2.7] [Form] Regression on non required ChoiceType handling","user":{"login":"hhamon","id":235550,"avatar_url":"https://avatars.githubusercontent.com/u/235550?v=3","gravatar_id":"","url":"https://api.github.com/users/hhamon","html_url":"https://github.com/hhamon","followers_url":"https://api.github.com/users/hhamon/followers","following_url":"https://api.github.com/users/hhamon/following{/other_user}","gists_url":"https://api.github.com/users/hhamon/gists{/gist_id}","starred_url":"https://api.github.com/users/hhamon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhamon/subscriptions","organizations_url":"https://api.github.com/users/hhamon/orgs","repos_url":"https://api.github.com/users/hhamon/repos","events_url":"https://api.github.com/users/hhamon/events{/privacy}","received_events_url":"https://api.github.com/users/hhamon/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/Critical","name":"Critical","color":"ff8c00"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Form","name":"Form","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-18T09:37:22Z","updated_at":"2015-05-04T11:32:01Z","closed_at":null,"body":"As of 03efce1b568379eac21d880e427090e43035f505, the `ChoiceType` is broken when dealing with empty value (or `required = false` option). Take the following simple example to illustrate the problem:\r\n\r\n```php\r\n<?php\r\n// ...\r\nclass DefaultController extends Controller\r\n{\r\n    /** @Route(\"/bug\") */\r\n    public function bugAction(Request $request)\r\n    {\r\n        $form = $this\r\n            ->createFormBuilder()\r\n            ->add('assignee', 'choice', [\r\n                'choices' => [\r\n                    'james' => 'James',\r\n                    'philip' => 'Philip',\r\n                    'elisabeth' => 'Elisabeth',\r\n                ],\r\n                'required' => false,\r\n            ])\r\n            ->getForm()\r\n        ;\r\n        $form->handleRequest($request);\r\n        \r\n        if ($form->isValid()) {\r\n            die('Yeah!');\r\n        }\r\n\r\n        return $this->render('default/bug.html.twig', [\r\n            'form' => $form->createView(),\r\n        ]);\r\n    }\r\n}\r\n```\r\nThe created form has one child field called `assignee`. It's a dropdown list of persons and it automatically includes an empty value when it's rendered thanks to the `required` option set to `false`. But when I submit the form with the empty value selected, an error message is displayed in the template saying: `This value is not valid.`. The data transformer used to convert the submitted view data asks the `ArrayKeyChoiceList` for the value `''`. But the latter doesn't have it so it throws a `TransformationFailedException`.\r\n\r\nThis regression affects all `choice` based form field types including `date`, `datetime`, `birthday`...\r\n\r\nWe still have less than 2 weeks before releasing Symfony 2.7.0, so this bug must be fixed asap.\r\n\r\n@webmozart can you look at the fix or tell me where I should make the fix please?"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/98682787","html_url":"https://github.com/symfony/symfony/issues/14393#issuecomment-98682787","issue_url":"https://api.github.com/repos/symfony/symfony/issues/14393","id":98682787,"user":{"login":"gyulaafodorr","id":7009636,"avatar_url":"https://avatars.githubusercontent.com/u/7009636?v=3","gravatar_id":"","url":"https://api.github.com/users/gyulaafodorr","html_url":"https://github.com/gyulaafodorr","followers_url":"https://api.github.com/users/gyulaafodorr/followers","following_url":"https://api.github.com/users/gyulaafodorr/following{/other_user}","gists_url":"https://api.github.com/users/gyulaafodorr/gists{/gist_id}","starred_url":"https://api.github.com/users/gyulaafodorr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyulaafodorr/subscriptions","organizations_url":"https://api.github.com/users/gyulaafodorr/orgs","repos_url":"https://api.github.com/users/gyulaafodorr/repos","events_url":"https://api.github.com/users/gyulaafodorr/events{/privacy}","received_events_url":"https://api.github.com/users/gyulaafodorr/received_events","type":"User","site_admin":false},"created_at":"2015-05-04T11:32:01Z","updated_at":"2015-05-04T11:32:01Z","body":"+1 :)"}}