Closed
Description
I have a form with the following code:
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
'multiple' => false,
'expanded' => false,
'choices' => array(
'label a' => false,
'label b' => true,
),
'choices_as_values' => true,
));
When submitting the form, none of the two radio buttons are selected, i.e. the values are lost.
I've written a unit test for it in imphil@71a59b7
Currently it fails with
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
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?
(This seems to be similar to #14877, but maybe not exactly the same, so I didn't want to hijack that issue.)