Permalink
Browse files

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
  • Loading branch information...
1 parent 89b8a91 commit 1c6daeb5a22006b8a66e27d3f0610cecdb2d4b6e @uwej711 uwej711 committed Mar 14, 2012
Showing with 7 additions and 7 deletions.
  1. +5 −5 Form/ChoiceList/ModelChoiceList.php
  2. +2 −2 Form/Type/ModelType.php
@@ -14,10 +14,10 @@
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 @@ public function __construct(ModelManagerInterface $modelManager, $class, $proper
}
$this->choices = $choices;
+ $this->load();
+ parent::__construct($this->choices);
}
/**
@@ -109,8 +111,6 @@ public function __construct(ModelManagerInterface $modelManager, $class, $proper
*/
protected function load()
{
- parent::load();
-
if (is_array($this->choices)) {
$entities = $this->choices;
} else if ($this->query) {
@@ -258,4 +258,4 @@ public function getClass()
{
return $this->class;
}
-}
+}
View
@@ -69,11 +69,11 @@ public function getDefaultOptions(array $options)
public function getParent(array $options)
{
- return $options['parent'];
+ return isset($options['parent']) ? $options['parent'] : 'choice';
}
public function getName()
{
return 'sonata_type_model';
}
-}
+}

0 comments on commit 1c6daeb

Please sign in to comment.