浏览代码

Fix some deprecated call

Thomas Rabaix 11 年之前
父节点
当前提交
e5fac1b775

+ 9 - 5
Form/ChoiceList/ModelChoiceList.php

@@ -13,7 +13,7 @@ namespace Sonata\AdminBundle\Form\ChoiceList;
 
 
 use Symfony\Component\PropertyAccess\PropertyAccess;
 use Symfony\Component\PropertyAccess\PropertyAccess;
 use Symfony\Component\PropertyAccess\PropertyPath;
 use Symfony\Component\PropertyAccess\PropertyPath;
-use Symfony\Component\Form\Exception\FormException;
+use Symfony\Component\Form\Exception\InvalidArgumentException;
 use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
 use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
 use Sonata\AdminBundle\Model\ModelManagerInterface;
 use Sonata\AdminBundle\Model\ModelManagerInterface;
 
 
@@ -233,14 +233,18 @@ class ModelChoiceList extends SimpleChoiceList
      * be persisted or added to the identity map before. Otherwise an
      * be persisted or added to the identity map before. Otherwise an
      * exception is thrown.
      * exception is thrown.
      *
      *
-     * @param  object        $entity The entity for which to get the identifier
-     * @throws FormException If the entity does not exist in Doctrine's
-     *                         identity map
+     * @param  object                   $entity The entity for which to get the identifier
+     * @throws InvalidArgumentException If the entity does not exist in Doctrine's
+     *                                  identity map
      * @return array
      * @return array
      */
      */
     public function getIdentifierValues($entity)
     public function getIdentifierValues($entity)
     {
     {
-        return $this->modelManager->getIdentifierValues($entity);
+        try {
+            return $this->modelManager->getIdentifierValues($entity);
+        } catch (\Exception $e) {
+            throw new InvalidArgumentException(sprintf("Unable to retrieve the identifier values for entity %s", get_class($entity)), 0, $e);
+        }
     }
     }
 
 
     /**
     /**

+ 0 - 1
Form/Type/ModelReferenceType.php

@@ -39,7 +39,6 @@ class ModelReferenceType extends AbstractType
             'compound'      => false,
             'compound'      => false,
             'model_manager' => null,
             'model_manager' => null,
             'class'         => null,
             'class'         => null,
-            'parent'        => 'text'
         ));
         ));
     }
     }
 
 

+ 1 - 1
Resources/views/Form/form_admin_fields.html.twig

@@ -74,7 +74,7 @@ file that was distributed with this source code.
 
 
 {% block choice_widget %}
 {% block choice_widget %}
 {% spaceless %}
 {% spaceless %}
-    {% if expanded %}
+    {% if compound %}
         <ul {{ block('widget_container_attributes_choice_widget') }}>
         <ul {{ block('widget_container_attributes_choice_widget') }}>
         {% for child in form %}
         {% for child in form %}
             <li>
             <li>