Sfoglia il codice sorgente

Remove non FQCNs on form types on AbstractAdmin (#4342)

There was a non FQCN on a form type only visible when using child admins
Jordi Sala Morales 8 anni fa
parent
commit
4913d17f33
1 ha cambiato i file con 12 aggiunte e 2 eliminazioni
  1. 12 2
      Admin/AbstractAdmin.php

+ 12 - 2
Admin/AbstractAdmin.php

@@ -838,14 +838,24 @@ abstract class AbstractAdmin implements AdminInterface, DomainObjectInterface
 
         // ok, try to limit to add parent filter
         if ($this->isChild() && $this->getParentAssociationMapping() && !$mapper->has($this->getParentAssociationMapping())) {
+            // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+.
+            $modelHiddenType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Sonata\AdminBundle\Form\Type\ModelHiddenType'
+                : 'sonata_type_model_hidden';
+
+            // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+.
+            $hiddenType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
+                : 'hidden';
+
             $mapper->add($this->getParentAssociationMapping(), null, array(
                 'show_filter' => false,
                 'label' => false,
-                'field_type' => 'sonata_type_model_hidden',
+                'field_type' => $modelHiddenType,
                 'field_options' => array(
                     'model_manager' => $this->getModelManager(),
                 ),
-                'operator_type' => 'hidden',
+                'operator_type' => $hiddenType,
             ), null, null, array(
                 'admin_code' => $this->getParent()->getCode(),
             ));