Browse Source

Fix compatibilty with mopa bootstrap bundle

Thomas Rabaix 11 years ago
parent
commit
18ae1b5f1a
2 changed files with 9 additions and 0 deletions
  1. 3 0
      Form/Extension/Field/Type/FormTypeFieldExtension.php
  2. 6 0
      Form/FormMapper.php

+ 3 - 0
Form/Extension/Field/Type/FormTypeFieldExtension.php

@@ -165,6 +165,9 @@ class FormTypeFieldExtension extends AbstractTypeExtension
         $resolver->setDefaults(array(
         $resolver->setDefaults(array(
             'sonata_admin'             => null,
             'sonata_admin'             => null,
             'sonata_field_description' => null,
             'sonata_field_description' => null,
+
+            // be compatible with mopa if not installed, avoid generating an exception for invalid option
+            'label_render'             => true,
         ));
         ));
     }
     }
 
 

+ 6 - 0
Form/FormMapper.php

@@ -103,6 +103,12 @@ class FormMapper extends BaseGroupedMapper
             // Note that the builder var is actually the formContractor:
             // Note that the builder var is actually the formContractor:
             $options = array_replace_recursive($this->builder->getDefaultOptions($type, $fieldDescription), $options);
             $options = array_replace_recursive($this->builder->getDefaultOptions($type, $fieldDescription), $options);
 
 
+            // be compatible with mopa if not installed, avoid generating an exception for invalid option
+            // force the default to false ...
+            if (!isset($options['label_render'])) {
+                $options['label_render'] = false;
+            }
+
             if (!isset($options['label'])) {
             if (!isset($options['label'])) {
                 $options['label'] = $this->admin->getLabelTranslatorStrategy()->getLabel($fieldDescription->getName(), 'form', 'label');
                 $options['label'] = $this->admin->getLabelTranslatorStrategy()->getLabel($fieldDescription->getName(), 'form', 'label');
             }
             }