Skip to content

Commit 9ca0cd1

Browse files
committed
feature #48343 [Form] [ChoiceType] Add a placeholder_attr option (elementaire)
This PR was merged into the 6.3 branch. Discussion ---------- [Form] [ChoiceType] Add a `placeholder_attr` option | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #38958 | Similar Pull Request | #47570 | License | MIT | Doc PR | symfony/symfony-docs#17469 Allow to custom the attributes of the placeholder (`data-*`, `title`, `disabled`, etc.). Commits ------- 2d4396ad50 [Form][ChoiceType] Add placeholder_attr field option
2 parents 41956b8 + 75d2c05 commit 9ca0cd1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Resources/views/Form/form_div_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
{%- endif -%}
6262
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
6363
{%- if placeholder is not none -%}
64-
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder != '' ? (translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain)) }}</option>
64+
<option value=""{% if placeholder_attr|default({}) %}{% with { attr: placeholder_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder != '' ? (translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain)) }}</option>
6565
{%- endif -%}
6666
{%- if preferred_choices|length > 0 -%}
6767
{% set options = preferred_choices %}

Resources/views/Form/foundation_5_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
{%- endif -%}
157157
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple" data-customforms="disabled"{% endif %}>
158158
{% if placeholder is not none -%}
159-
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain) }}</option>
159+
<option value=""{% if placeholder_attr|default({}) %}{% with { attr: placeholder_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}{% if required and value is empty %} selected="selected"{% endif %}>{{ translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain) }}</option>
160160
{%- endif %}
161161
{%- if preferred_choices|length > 0 -%}
162162
{% set options = preferred_choices %}

0 commit comments

Comments
 (0)