Преглед изворни кода

Add choices_as_values to ModelType (#4445)

Jordi Sala Morales пре 8 година
родитељ
комит
faae5ed604
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      Form/Type/ModelType.php

+ 4 - 0
Form/Type/ModelType.php

@@ -110,6 +110,10 @@ class ModelType extends AbstractType
                     $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 {
             $options['choice_list'] = function (Options $options, $previousValue) use ($propertyAccessor) {
                 if ($previousValue && count($choices = $previousValue->getChoices())) {