소스 검색

avoid rendering the `ChoiceType` separator if all `choices` are `preferred_choices`

Christian Raue 14 년 전
부모
커밋
c558b78bc6

+ 3 - 1
src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

@@ -57,7 +57,9 @@
         {% if preferred_choices|length > 0 %}
             {% set options = preferred_choices %}
             {{ block('widget_choice_options') }}
-            <option disabled="disabled">{{ separator }}</option>
+            {% if choices|length > 0 %}
+                <option disabled="disabled">{{ separator }}</option>
+            {% endif %}
         {% endif %}
         {% set options = choices %}
         {{ block('widget_choice_options') }}

+ 3 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget.html.php

@@ -13,7 +13,9 @@
         <?php if (null !== $empty_value): ?><option value=""><?php echo $view->escape($view['translator']->trans($empty_value)) ?></option><?php endif; ?>
         <?php if (count($preferred_choices) > 0): ?>
             <?php echo $view['form']->renderBlock('choice_options', array('options' => $preferred_choices)) ?>
-            <option disabled="disabled"><?php echo $separator ?></option>
+            <?php if (count($choices) > 0): ?>
+                <option disabled="disabled"><?php echo $separator ?></option>
+            <?php endif ?>
         <?php endif ?>
         <?php echo $view['form']->renderBlock('choice_options', array('options' => $choices)) ?>
     </select>