Преглед изворни кода

[Form] fixed choices when keys are integers

This fixes choices when all the keys are strings (but integers really).

That's because in PHP, if you have the following array:

array('1' => 'foo', '2' => 'bar');

PHP "converts" it automatically to the following array:

array(1 => 'foo', 2 => 'bar');
Fabien Potencier пре 14 година
родитељ
комит
2573c8968f

+ 1 - 1
src/Symfony/Component/Form/Extension/Core/DataTransformer/ScalarToBooleanChoicesTransformer.php

@@ -87,7 +87,7 @@ class ScalarToBooleanChoicesTransformer implements DataTransformerInterface
 
         foreach ($value as $choice => $selected) {
             if ($selected) {
-                return $choice;
+                return (string) $choice;
             }
         }