Browse Source

Used classname in form type name (#4118)

François-Xavier de Guillebon 9 years ago
parent
commit
1541dd8475

+ 4 - 1
Form/Type/ChoiceFieldMaskType.php

@@ -77,7 +77,10 @@ class ChoiceFieldMaskType extends AbstractType
      */
     public function getParent()
     {
-        return 'choice';
+        // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+        return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+            ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+            : 'choice';
     }
 
     /**

+ 4 - 1
Form/Type/Filter/DateRangeType.php

@@ -92,7 +92,10 @@ class DateRangeType extends AbstractType
         }
 
         $builder
-            ->add('type', 'choice', $choiceOptions)
+            // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+            ->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+                : 'choice', $choiceOptions)
             ->add('value', $options['field_type'], $options['field_options'])
         ;
     }

+ 4 - 1
Form/Type/Filter/DateTimeRangeType.php

@@ -92,7 +92,10 @@ class DateTimeRangeType extends AbstractType
         }
 
         $builder
-            ->add('type', 'choice', $choiceOptions)
+            // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+            ->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+                : 'choice', $choiceOptions)
             ->add('value', $options['field_type'], $options['field_options'])
         ;
     }

+ 4 - 1
Form/Type/Filter/DateTimeType.php

@@ -108,7 +108,10 @@ class DateTimeType extends AbstractType
         }
 
         $builder
-            ->add('type', 'choice', $choiceOptions)
+            // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+            ->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+                : 'choice', $choiceOptions)
             ->add('value', $options['field_type'], array_merge(array('required' => false), $options['field_options']))
         ;
     }

+ 4 - 1
Form/Type/Filter/DateType.php

@@ -108,7 +108,10 @@ class DateType extends AbstractType
         }
 
         $builder
-            ->add('type', 'choice', $choiceOptions)
+            // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+            ->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+                : 'choice', $choiceOptions)
             ->add('value', $options['field_type'], array_merge(array('required' => false), $options['field_options']))
         ;
     }

+ 6 - 2
Form/Type/Filter/DefaultType.php

@@ -68,9 +68,13 @@ class DefaultType extends AbstractType
     public function configureOptions(OptionsResolver $resolver)
     {
         $resolver->setDefaults(array(
-            'operator_type' => 'hidden',
+            'operator_type' => method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
+                : 'hidden', // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
             'operator_options' => array(),
-            'field_type' => 'text',
+            'field_type' => method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\TextType'
+                : 'text', // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
             'field_options' => array(),
         ));
     }

+ 4 - 1
Form/Type/Filter/NumberType.php

@@ -103,7 +103,10 @@ class NumberType extends AbstractType
         }
 
         $builder
-            ->add('type', 'choice', $choiceOptions)
+            // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+            ->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+                : 'choice', $choiceOptions)
             ->add('value', $options['field_type'], array_merge(array('required' => false), $options['field_options']))
         ;
     }

+ 4 - 1
Form/Type/ModelHiddenType.php

@@ -60,7 +60,10 @@ class ModelHiddenType extends AbstractType
      */
     public function getParent()
     {
-        return 'hidden';
+        // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+        return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+            ? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
+            : 'hidden';
     }
 
     /**

+ 4 - 1
Form/Type/ModelListType.php

@@ -96,7 +96,10 @@ class ModelListType extends AbstractType
      */
     public function getParent()
     {
-        return 'text';
+        // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+        return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+            ? 'Symfony\Component\Form\Extension\Core\Type\TextType'
+            : 'text';
     }
 
     /**

+ 4 - 1
Form/Type/ModelReferenceType.php

@@ -59,7 +59,10 @@ class ModelReferenceType extends AbstractType
      */
     public function getParent()
     {
-        return 'text';
+        // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+        return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+            ? 'Symfony\Component\Form\Extension\Core\Type\TextType'
+            : 'text';
     }
 
     /**

+ 4 - 1
Form/Type/ModelType.php

@@ -171,7 +171,10 @@ class ModelType extends AbstractType
      */
     public function getParent()
     {
-        return 'choice';
+        // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+        return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+            ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+            : 'choice';
     }
 
     /**

+ 4 - 1
Tests/Form/Type/ChoiceFieldMaskTypeTest.php

@@ -49,6 +49,9 @@ class ChoiceFieldMaskTypeTest extends TypeTestCase
     public function testGetParent()
     {
         $type = new ChoiceFieldMaskType();
-        $this->assertSame('choice', $type->getParent());
+        // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+        $this->assertSame(method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+            ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+            : 'choice', $type->getParent());
     }
 }

+ 4 - 1
Tests/Form/Type/ModelHiddenTypeTest.php

@@ -45,6 +45,9 @@ class ModelHiddenTypeTest extends TypeTestCase
     public function testGetParent()
     {
         $type = new ModelHiddenType();
-        $this->assertSame('hidden', $type->getParent());
+        // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
+        $this->assertSame(method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+            ? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
+            : 'hidden', $type->getParent());
     }
 }