Skip to content

Commit c558b78

Browse files
committed
avoid rendering the ChoiceType separator if all choices are preferred_choices
1 parent fe1f42f commit c558b78

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
{% if preferred_choices|length > 0 %}
5858
{% set options = preferred_choices %}
5959
{{ block('widget_choice_options') }}
60-
<option disabled="disabled">{{ separator }}</option>
60+
{% if choices|length > 0 %}
61+
<option disabled="disabled">{{ separator }}</option>
62+
{% endif %}
6163
{% endif %}
6264
{% set options = choices %}
6365
{{ block('widget_choice_options') }}

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget.html.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
<?php if (null !== $empty_value): ?><option value=""><?php echo $view->escape($view['translator']->trans($empty_value)) ?></option><?php endif; ?>
1414
<?php if (count($preferred_choices) > 0): ?>
1515
<?php echo $view['form']->renderBlock('choice_options', array('options' => $preferred_choices)) ?>
16-
<option disabled="disabled"><?php echo $separator ?></option>
16+
<?php if (count($choices) > 0): ?>
17+
<option disabled="disabled"><?php echo $separator ?></option>
18+
<?php endif ?>
1719
<?php endif ?>
1820
<?php echo $view['form']->renderBlock('choice_options', array('options' => $choices)) ?>
1921
</select>

0 commit comments

Comments
 (0)