<p dir="auto">I have a form with the following code:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$form = $this-&gt;factory-&gt;create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
  'multiple' =&gt; false,
  'expanded' =&gt; false,
  'choices' =&gt; array(
      'label a' =&gt; false,
      'label b' =&gt; true,
  ),
  'choices_as_values' =&gt; true,
));"><pre class="notranslate"><span class="pl-s1"><span class="pl-c1">$</span>form</span> = <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">factory</span>-&gt;<span class="pl-en">create</span>(<span class="pl-s">'Symfony\Component\Form\Extension\Core\Type\ChoiceType'</span>, <span class="pl-c1">null</span>, <span class="pl-en">array</span>(
  <span class="pl-s">'multiple'</span> =&gt; <span class="pl-c1">false</span>,
  <span class="pl-s">'expanded'</span> =&gt; <span class="pl-c1">false</span>,
  <span class="pl-s">'choices'</span> =&gt; <span class="pl-en">array</span>(
      <span class="pl-s">'label a'</span> =&gt; <span class="pl-c1">false</span>,
      <span class="pl-s">'label b'</span> =&gt; <span class="pl-c1">true</span>,
  ),
  <span class="pl-s">'choices_as_values'</span> =&gt; <span class="pl-c1">true</span>,
));</pre></div>
<p dir="auto">When submitting the form, none of the two radio buttons are selected, i.e. the values are lost.</p>
<p dir="auto">I've written a unit test for it in <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/imphil/symfony/commit/71a59b79fe2afb5db1fd5e5e28f46b52b7e961cd/hovercard" href="https://github.com/imphil/symfony/commit/71a59b79fe2afb5db1fd5e5e28f46b52b7e961cd">imphil@<tt>71a59b7</tt></a></p>
<p dir="auto">Currently it fails with</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="There were 2 failures:

1) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testSubmitSingleExpandedBooleanValueFalse
Failed asserting that false is identical to '0'.

/home/philipp/src/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:354

2) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testSubmitSingleExpandedBooleanValueTrue
Failed asserting that true is identical to '1'.

/home/philipp/src/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:373"><pre class="notranslate"><code class="notranslate">There were 2 failures:

1) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testSubmitSingleExpandedBooleanValueFalse
Failed asserting that false is identical to '0'.

/home/philipp/src/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:354

2) Symfony\Component\Form\Tests\Extension\Core\Type\ChoiceTypeTest::testSubmitSingleExpandedBooleanValueTrue
Failed asserting that true is identical to '1'.

/home/philipp/src/symfony/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php:373
</code></pre></div>
<p dir="auto">The problem only happens with boolean values and expanded=true. It seems that a proper conversion to the view data is missing. Unfortunately I have no idea about the inner workings of Symfony -- maybe someone with a bit more experience can have a look?</p>
<p dir="auto">(This seems to be similar to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="85524044" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/14877" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/14877/hovercard" href="https://github.com/symfony/symfony/issues/14877">#14877</a>, but maybe not exactly the same, so I didn't want to hijack that issue.)</p>
<p dir="auto">Hi,</p>
<p dir="auto">I'm currently updating my code to symfony 2.7 and I saw a weird behavior with choice field form with boolean value.</p>
<p dir="auto">Here is my form class:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php
namespace Icap\DropzoneBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DropzoneCommonType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            -&gt;add('peerReview', 'choice', array(
                'required' =&gt; true,
                'choices' =&gt; array(
                    'Standard evaluation' =&gt; false,
                    'Peer review evaluation' =&gt; true
                ),
                'choices_as_values' =&gt; true,
                'expanded' =&gt; true,
                'multiple' =&gt; false
            ));

    }

    public function getName()
    {
        return 'icap_dropzone_common_form';
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver-&gt;setDefaults(
            array(
                'data_class' =&gt; 'Icap\DropzoneBundle\Entity\Dropzone',
                'language' =&gt; 'en',
                'translation_domain' =&gt; 'icap_dropzone',
                'date_format' =&gt; DateType::HTML5_FORMAT,
            )
        );
    }
}"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>
<span class="pl-k">namespace</span> <span class="pl-v">Icap</span>\<span class="pl-v">DropzoneBundle</span>\<span class="pl-v">Form</span>;

<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Form</span>\<span class="pl-v">AbstractType</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Form</span>\<span class="pl-v">FormBuilderInterface</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">OptionsResolver</span>\<span class="pl-v">OptionsResolver</span>;

<span class="pl-k">class</span> <span class="pl-v">DropzoneCommonType</span> <span class="pl-k">extends</span> <span class="pl-v">AbstractType</span>
{
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">buildForm</span>(<span class="pl-smi"><span class="pl-smi">FormBuilderInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>builder</span>, <span class="pl-smi">array</span> <span class="pl-s1"><span class="pl-c1">$</span>options</span>)
    {
        <span class="pl-s1"><span class="pl-c1">$</span>builder</span>
            -&gt;<span class="pl-en">add</span>(<span class="pl-s">'peerReview'</span>, <span class="pl-s">'choice'</span>, <span class="pl-en">array</span>(
                <span class="pl-s">'required'</span> =&gt; <span class="pl-c1">true</span>,
                <span class="pl-s">'choices'</span> =&gt; <span class="pl-en">array</span>(
                    <span class="pl-s">'Standard evaluation'</span> =&gt; <span class="pl-c1">false</span>,
                    <span class="pl-s">'Peer review evaluation'</span> =&gt; <span class="pl-c1">true</span>
                ),
                <span class="pl-s">'choices_as_values'</span> =&gt; <span class="pl-c1">true</span>,
                <span class="pl-s">'expanded'</span> =&gt; <span class="pl-c1">true</span>,
                <span class="pl-s">'multiple'</span> =&gt; <span class="pl-c1">false</span>
            ));

    }

    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">getName</span>()
    {
        <span class="pl-k">return</span> <span class="pl-s">'icap_dropzone_common_form'</span>;
    }

    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">configureOptions</span>(<span class="pl-smi"><span class="pl-smi">OptionsResolver</span></span> <span class="pl-s1"><span class="pl-c1">$</span>resolver</span>)
    {
        <span class="pl-s1"><span class="pl-c1">$</span>resolver</span>-&gt;<span class="pl-en">setDefaults</span>(
            <span class="pl-en">array</span>(
                <span class="pl-s">'data_class'</span> =&gt; <span class="pl-s">'Icap\DropzoneBundle\Entity\Dropzone'</span>,
                <span class="pl-s">'language'</span> =&gt; <span class="pl-s">'en'</span>,
                <span class="pl-s">'translation_domain'</span> =&gt; <span class="pl-s">'icap_dropzone'</span>,
                <span class="pl-s">'date_format'</span> =&gt; <span class="pl-v">DateType</span>::<span class="pl-c1">HTML5_FORMAT</span>,
            )
        );
    }
}</pre></div>
<p dir="auto">And how the field is displayed, pretty classic:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{{ form_row(form.peerReview, {'label_attr': {'style': 'display: none;'}}) }}"><pre class="notranslate"><code class="notranslate">{{ form_row(form.peerReview, {'label_attr': {'style': 'display: none;'}}) }}
</code></pre></div>
<p dir="auto">But at the display of the form the field doesn't have its value checked, the radio button here.<br>
The radio button is checked at the display of the form only after submitting it.</p>
<p dir="auto">I checked in the debug bar to see what was in the form and I found what I think it's an error.<br>
Before 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.<br>
After submitting the value is boolean, what I expect it to be, but before submission it's an integer.</p>
<p dir="auto">Is it a bug or am I missing something?</p>