Browse Source

Add choices_as_values to ModelType (#4445)

Jordi Sala Morales 8 years ago
parent
commit
faae5ed604
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Form/Type/ModelType.php

+ 4 - 0
Form/Type/ModelType.php

@@ -110,6 +110,10 @@ class ModelType extends AbstractType
                     $propertyAccessor
                     $propertyAccessor
                 );
                 );
             };
             };
+            // NEXT_MAJOR: Remove this when dropping support for SF 2.8
+            if (method_exists('Symfony\Component\Form\FormTypeInterface', 'setDefaultOptions')) {
+                $options['choices_as_values'] = true;
+            }
         } else {
         } else {
             $options['choice_list'] = function (Options $options, $previousValue) use ($propertyAccessor) {
             $options['choice_list'] = function (Options $options, $previousValue) use ($propertyAccessor) {
                 if ($previousValue && count($choices = $previousValue->getChoices())) {
                 if ($previousValue && count($choices = $previousValue->getChoices())) {