Skip to content

Commit f12d2b7

Browse files
committed
minor #19574 [TwigBundle] Add a check for choice's attributes emptiness before calling block('attributes') (Evgeniy Tetenchuk, johnatannvmd)
This PR was merged into the 2.7 branch. Discussion ---------- [TwigBundle] Add a check for choice's attributes emptiness before calling block('attributes') | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Remove unnecessary block calling for choices without "choice_attr" option. This check gain the performance on a large datasets. Previous Pull to master #19527 Commits ------- bf6748d Move space from the before 'if' to the after 'if' d1cf4d1 [TwigBundle] Add a check for choice's attributes emptiness before calling block('attributes')
2 parents adb7033 + bf6748d commit f12d2b7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@
7979
{{- block('choice_widget_options') -}}
8080
</optgroup>
8181
{%- else -%}
82-
{% set attr = choice.attr %}
83-
<option value="{{ choice.value }}" {{ block('attributes') }}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
82+
<option value="{{ choice.value }}"{% if choice.attr %} {% set attr = choice.attr %}{{ block('attributes') }}{% endif %}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
8483
{%- endif -%}
8584
{% endfor %}
8685
{%- endblock choice_widget_options -%}

0 commit comments

Comments
 (0)