{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/14712","labels_url":"https://api.github.com/repos/symfony/symfony/issues/14712/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/14712/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/14712/events","html_url":"https://github.com/symfony/symfony/issues/14712","id":78862929,"number":14712,"title":"[Form][2.7] Preselection of choice field with boolean value","user":{"login":"maxailloud","id":792787,"avatar_url":"https://avatars.githubusercontent.com/u/792787?v=3","gravatar_id":"","url":"https://api.github.com/users/maxailloud","html_url":"https://github.com/maxailloud","followers_url":"https://api.github.com/users/maxailloud/followers","following_url":"https://api.github.com/users/maxailloud/following{/other_user}","gists_url":"https://api.github.com/users/maxailloud/gists{/gist_id}","starred_url":"https://api.github.com/users/maxailloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxailloud/subscriptions","organizations_url":"https://api.github.com/users/maxailloud/orgs","repos_url":"https://api.github.com/users/maxailloud/repos","events_url":"https://api.github.com/users/maxailloud/events{/privacy}","received_events_url":"https://api.github.com/users/maxailloud/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/symfony/symfony/labels/Form","name":"Form","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-05-21T06:57:46Z","updated_at":"2015-06-20T10:55:42Z","closed_at":null,"body":"Hi,\r\n\r\nI'm currently updating my code to symfony 2.7 and I saw a weird behavior with choice field form with boolean value.\r\n\r\nHere is my form class:\r\n\r\n```php\r\n<?php\r\nnamespace Icap\\DropzoneBundle\\Form;\r\n\r\nuse Symfony\\Component\\Form\\AbstractType;\r\nuse Symfony\\Component\\Form\\FormBuilderInterface;\r\nuse Symfony\\Component\\OptionsResolver\\OptionsResolver;\r\n\r\nclass DropzoneCommonType extends AbstractType\r\n{\r\n    public function buildForm(FormBuilderInterface $builder, array $options)\r\n    {\r\n        $builder\r\n            ->add('peerReview', 'choice', array(\r\n                'required' => true,\r\n                'choices' => array(\r\n                    'Standard evaluation' => false,\r\n                    'Peer review evaluation' => true\r\n                ),\r\n                'choices_as_values' => true,\r\n                'expanded' => true,\r\n                'multiple' => false\r\n            ));\r\n\r\n    }\r\n\r\n    public function getName()\r\n    {\r\n        return 'icap_dropzone_common_form';\r\n    }\r\n\r\n    public function configureOptions(OptionsResolver $resolver)\r\n    {\r\n        $resolver->setDefaults(\r\n            array(\r\n                'data_class' => 'Icap\\DropzoneBundle\\Entity\\Dropzone',\r\n                'language' => 'en',\r\n                'translation_domain' => 'icap_dropzone',\r\n                'date_format' => DateType::HTML5_FORMAT,\r\n            )\r\n        );\r\n    }\r\n}\r\n```\r\n\r\nAnd how the field is displayed, pretty classic:\r\n```\r\n{{ form_row(form.peerReview, {'label_attr': {'style': 'display: none;'}}) }}\r\n```\r\n\r\nBut at the display of the form the field doesn't have its value checked, the radio button here.\r\nThe radio button is checked at the display of the form only after submitting it.\r\n\r\nI checked in the debug bar to see what was in the form and I found what I think it's an error.\r\nBefore submitting the form the value, and the data, of the field peerReview is 1, and after submitting the value, and the data to, is true. I checked in my object and the attribute is a boolean with true as value.\r\nAfter submitting the value is boolean, what I expect it to be, but before submission it's an integer.\r\n\r\nIs it a bug or am I missing something?"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/113745978","html_url":"https://github.com/symfony/symfony/issues/14712#issuecomment-113745978","issue_url":"https://api.github.com/repos/symfony/symfony/issues/14712","id":113745978,"user":{"login":"MJBGO","id":8344487,"avatar_url":"https://avatars.githubusercontent.com/u/8344487?v=3","gravatar_id":"","url":"https://api.github.com/users/MJBGO","html_url":"https://github.com/MJBGO","followers_url":"https://api.github.com/users/MJBGO/followers","following_url":"https://api.github.com/users/MJBGO/following{/other_user}","gists_url":"https://api.github.com/users/MJBGO/gists{/gist_id}","starred_url":"https://api.github.com/users/MJBGO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MJBGO/subscriptions","organizations_url":"https://api.github.com/users/MJBGO/orgs","repos_url":"https://api.github.com/users/MJBGO/repos","events_url":"https://api.github.com/users/MJBGO/events{/privacy}","received_events_url":"https://api.github.com/users/MJBGO/received_events","type":"User","site_admin":false},"created_at":"2015-06-20T10:55:42Z","updated_at":"2015-06-20T10:55:42Z","body":"Could we have a fix for the 2.7 branch ? I'm facing the same problem. When I go on an edit form, all false values are not preselected on radios.\r\n\r\nTrue value (1) : \"oui\" is selected because 1 in bdd\r\n\r\n![image](https://cloud.githubusercontent.com/assets/8344487/8266966/e449ed5a-174a-11e5-985a-60d916c0a81c.png)\r\n\r\nFalse value (0) : \"non\" should be selected because 0 in bdd\r\n\r\n![image](https://cloud.githubusercontent.com/assets/8344487/8266973/4b4059ea-174b-11e5-944c-d3e3b71fd502.png)\r\n\r\nCode : \r\n\r\n```php\r\n->add('showIdentity', 'choice', array(\r\n                'choices' => array(\r\n                    true => 'Oui',\r\n                    false => 'Non'\r\n                ),\r\n                'multiple' => false,\r\n                'expanded' => true\r\n            ))\r\n```\r\n\r\nThis is happening since the upgrade to 2.7.0 (and is still an issue on 2.7.1), on all my projects."}}