Browse Source

Fixed Symfony deprecation warning on filter operator type (#4114)

François-Xavier de Guillebon 9 years ago
parent
commit
310dbd36e1
1 changed files with 5 additions and 2 deletions
  1. 5 2
      Form/Type/Filter/ChoiceType.php

+ 5 - 2
Form/Type/Filter/ChoiceType.php

@@ -86,7 +86,8 @@ class ChoiceType extends AbstractType
         }
 
         $operatorChoices = array();
-        if ($options['operator_type'] !== 'hidden') {
+        // NEXT_MAJOR: Remove first check (when requirement of Symfony is >= 2.8)
+        if ($options['operator_type'] !== 'hidden' && $options['operator_type'] !== 'Symfony\Component\Form\Extension\Core\Type\HiddenType') {
             $operatorChoices['choices'] = $choices;
 
             // NEXT_MAJOR: Remove this hack, when dropping support for symfony <2.7
@@ -119,7 +120,9 @@ class ChoiceType extends AbstractType
         $resolver->setDefaults(array(
             'field_type' => 'choice',
             'field_options' => array(),
-            'operator_type' => 'choice',
+            'operator_type' => method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+                : 'choice', // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
             'operator_options' => array(),
         ));
     }