Browse Source

Fix deprecated call

Thomas Rabaix 12 years ago
parent
commit
000acf2229
3 changed files with 19 additions and 3 deletions
  1. 1 1
      Admin/Admin.php
  2. 17 1
      Form/Extension/Field/Type/FormTypeFieldExtension.php
  3. 1 1
      Form/Type/AdminType.php

+ 1 - 1
Admin/Admin.php

@@ -1220,7 +1220,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
         $admin = $this;
 
         // add the custom inline validation option
-        $metadata = $this->validator->getMetadataFactory()->getClassMetadata($this->getClass());
+        $metadata = $this->validator->getMetadataFactory()->getMetadataFor($this->getClass());
 
         $metadata->addConstraint(new InlineConstraint(array(
             'service' => $this,

+ 17 - 1
Form/Extension/Field/Type/FormTypeFieldExtension.php

@@ -75,7 +75,7 @@ class FormTypeFieldExtension extends AbstractTypeExtension
      */
     protected function getClass(FormBuilderInterface $formBuilder)
     {
-        foreach ($formBuilder->getTypes() as $type) {
+        foreach ($this->getTypes($formBuilder) as $type) {
             if (isset($this->defaultClasses[$type->getName()])) {
                 return $this->defaultClasses[$type->getName()];
             }
@@ -84,6 +84,22 @@ class FormTypeFieldExtension extends AbstractTypeExtension
         return '';
     }
 
+    /**
+     * @param \Symfony\Component\Form\FormBuilderInterface $formBuilder
+     *
+     * @return array
+     */
+    protected function getTypes(FormBuilderInterface $formBuilder)
+    {
+        $types = array();
+
+        for ($type = $formBuilder->getType(); null !== $type; $type = $type->getParent()) {
+            array_unshift($types, $type->getInnerType());
+        }
+
+        return $types;
+    }
+
     /**
      * @param FormView      $view
      * @param FormInterface $form

+ 1 - 1
Form/Type/AdminType.php

@@ -37,7 +37,7 @@ class AdminType extends AbstractType
 
         $admin->defineFormBuilder($builder);
 
-        $builder->prependClientTransformer(new ArrayToModelTransformer($admin->getModelManager(), $admin->getClass()));
+        $builder->addModelTransformer(new ArrayToModelTransformer($admin->getModelManager(), $admin->getClass()));
     }
 
     /**