Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 209b32f

Browse filesBrowse files
committed
feature #26502 [Form] Add Bootstrap 4 style for field FileType (zenmate)
This PR was squashed before being merged into the 4.1-dev branch (closes #26502). Discussion ---------- [Form] Add Bootstrap 4 style for field FileType | Q | A | ------------- | --- | Branch? | master<!-- see below --> | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #26464 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Write a short README entry for your feature/bugfix here (replace this comment block.) This will help people understand your PR and can be used as a start of the Doc PR. Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. --> Commits ------- df57718 [Form] Add Bootstrap 4 style for field FileType
2 parents c2a67aa + df57718 commit 209b32f
Copy full SHA for 209b32f

File tree

1 file changed

+12
-1
lines changed
Filter options

1 file changed

+12
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig
+12-1Lines 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 -%}
@@ -263,6 +265,15 @@
263265
</{{ element|default('div') }}>
264266
{%- endblock form_row %}
265267

268+
{% block file_row -%}
269+
<div class="form-group">
270+
<{{ element|default('div') }} class="custom-file">
271+
{{- form_widget(form) -}}
272+
{{- form_label(form) -}}
273+
</{{ element|default('div') }}>
274+
</div>
275+
{% endblock %}
276+
266277
{# Errors #}
267278

268279
{% block form_errors -%}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.