Procházet zdrojové kódy

Added and tested EntityToIDTransformer to transform Many-To-One and One-To-One entities into their identifier values

Benjamin Eberlei před 14 roky
rodič
revize
ec3b3f7637

+ 0 - 1
src/Symfony/Bundle/DoctrineBundle/Tests/Form/ValueTransformer/CollectionToChoiceTransformerTest.php

@@ -28,7 +28,6 @@ class CollectionToChoiceTransformerTest extends \Symfony\Bundle\DoctrineBundle\T
         try {
             $schemaTool->createSchema($classes);
         } catch(\Exception $e) {
-            echo $e->getMessage();
         }
     }
 

+ 4 - 2
src/Symfony/Component/Form/ChoiceField.php

@@ -166,6 +166,7 @@ class ChoiceField extends HybridField
     protected function transform($value)
     {
         if ($this->getOption('expanded')) {
+            $value = parent::transform($value);
             $choices = $this->getOption('choices');
 
             foreach ($choices as $choice => $_) {
@@ -174,9 +175,10 @@ class ChoiceField extends HybridField
                     : ($choice === $value);
             }
 
-            $value = $choices;
+            return $choices;
+        } else {
+            return parent::transform($value);
         }
-        return parent::transform($value);
     }
 
     /**