소스 검색

[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개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/Symfony/Component/Form/Extension/Core/DataTransformer/ScalarToBooleanChoicesTransformer.php

+ 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;
             }
         }