Przeglądaj źródła

Adjust to latest symfony 2.1-DEV

See also https://github.com/symfony/symfony/blob/master/UPGRADE-2.1.md to explain the changes.

BC break with symfony 2.0
Uwe Jäger 13 lat temu
rodzic
commit
1c6daeb5a2
2 zmienionych plików z 7 dodań i 7 usunięć
  1. 5 5
      Form/ChoiceList/ModelChoiceList.php
  2. 2 2
      Form/Type/ModelType.php

+ 5 - 5
Form/ChoiceList/ModelChoiceList.php

@@ -14,10 +14,10 @@ namespace Sonata\AdminBundle\Form\ChoiceList;
 use Symfony\Component\Form\Util\PropertyPath;
 use Symfony\Component\Form\Exception\FormException;
 use Symfony\Component\Form\Exception\UnexpectedTypeException;
-use Symfony\Component\Form\Extension\Core\ChoiceList\ArrayChoiceList;
+use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
 use Sonata\AdminBundle\Model\ModelManagerInterface;
 
-class ModelChoiceList extends ArrayChoiceList
+class ModelChoiceList extends SimpleChoiceList
 {
     /**
      * @var \Sonata\AdminBundle\Model\ModelManagerInterface
@@ -86,6 +86,8 @@ class ModelChoiceList extends ArrayChoiceList
         }
 
         $this->choices = $choices;
+        $this->load();
+        parent::__construct($this->choices);
     }
 
     /**
@@ -109,8 +111,6 @@ class ModelChoiceList extends ArrayChoiceList
      */
     protected function load()
     {
-        parent::load();
-
         if (is_array($this->choices)) {
             $entities = $this->choices;
         } else if ($this->query) {
@@ -258,4 +258,4 @@ class ModelChoiceList extends ArrayChoiceList
     {
       return $this->class;
     }
-}
+}

+ 2 - 2
Form/Type/ModelType.php

@@ -69,11 +69,11 @@ class ModelType extends AbstractType
 
     public function getParent(array $options)
     {
-        return $options['parent'];
+        return isset($options['parent']) ? $options['parent'] : 'choice';
     }
 
     public function getName()
     {
         return 'sonata_type_model';
     }
-}
+}