10000 [Form] Add Bootstrap 4 style for field FileType · symfony/symfony@df57718 · GitHub
[go: up one dir, main page]

Skip to content

Commit df57718

Browse files
zenmatefabpot
zenmate
authored andcommitted
[Form] Add Bootstrap 4 style for field FileType
1 parent 9e82562 commit df57718

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117

118118
{% block form_widget_simple -%}
119119
{% if type is not defined or type != 'hidden' %}
120-
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control' ~ (type|default('') == 'file' ? '-file' : ''))|trim}) -%}
120+
{%- set attr = attr|merge({class: (attr.class|default('') ~ (type|default('') == 'file' ? ' custom-file-input' : ' form-control'))|trim}) -%}
121121
{% endif %}
122122
{%- if type is defined and (type == 'range' or type == 'color') %}
123123
{# Attribute "required" is not supported #}
@@ -187,6 +187,8 @@
187187
{%- if compound is defined and compound -%}
188188
{%- set element = 'legend' -%}
189189
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%}
190+
{% elseif type is defined and type == 'file' %}
191+
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' custom-file-label')|trim}) -%}
190192
{%- else -%}
191193
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
192194
{%- endif -%}
@@ -257,6 +259,15 @@
257259
</{{ element|default('div') }}>
258260
{%- endblock form_row %}
259261

262+
{% block file_row -%}
263+
<div class="form-group">
264+
<{{ element|default('div') }} class="custom-file">
265+
{{- form_widget(form) -}}
266+
{{- form_label(form) -}}
267+
</{{ element|default('div') }}>
268+
</div>
269+
{% endblock %}
270+
260271
{# Errors #}
261272

262273
{% block form_errors -%}

0 commit comments

Comments
 (0)
0