Browse Source

Merge pull request #4085 from amine2z/fix_acl_form_type

fix(bc): form type support of >2.8
Christian Gripp 9 years ago
parent
commit
26443ec3f7
1 changed files with 16 additions and 2 deletions
  1. 16 2
      Form/Type/AclMatrixType.php

+ 16 - 2
Form/Type/AclMatrixType.php

@@ -33,10 +33,24 @@ class AclMatrixType extends AbstractType
         $aclValueType = $options['acl_value'] instanceof UserInterface ? 'user' : 'role';
         $aclValueType = $options['acl_value'] instanceof UserInterface ? 'user' : 'role';
         $aclValueData = $options['acl_value'] instanceof UserInterface ? $options['acl_value']->getUsername() : $options['acl_value'];
         $aclValueData = $options['acl_value'] instanceof UserInterface ? $options['acl_value']->getUsername() : $options['acl_value'];
 
 
-        $builder->add($aclValueType, 'hidden', array('data' => $aclValueData));
+        $builder->add(
+            $aclValueType,
+            // NEXT_MAJOR: remove when dropping Symfony <2.8 support
+            method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
+                : 'hidden',
+            array('data' => $aclValueData)
+        );
 
 
         foreach ($options['permissions'] as $permission => $attributes) {
         foreach ($options['permissions'] as $permission => $attributes) {
-            $builder->add($permission, 'checkbox', $attributes);
+            $builder->add(
+                $permission,
+                // NEXT_MAJOR: remove when dropping Symfony <2.8 support
+                method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                    ? 'Symfony\Component\Form\Extension\Core\Type\CheckboxType'
+                    : 'checkbox',
+                $attributes
+            );
         }
         }
     }
     }