Skip to content

Commit

Permalink
feature #26502 [Form] Add Bootstrap 4 style for field FileType (zenmate)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed Mar 27, 2018
2 parents c2a67aa + df57718 commit 209b32f
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -117,7 +117,7 @@

{% block form_widget_simple -%}
{% if type is not defined or type != 'hidden' %}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control' ~ (type|default('') == 'file' ? '-file' : ''))|trim}) -%}
{%- set attr = attr|merge({class: (attr.class|default('') ~ (type|default('') == 'file' ? ' custom-file-input' : ' form-control'))|trim}) -%}
{% endif %}
{%- if type is defined and (type == 'range' or type == 'color') %}
{# Attribute "required" is not supported #}
Expand Down Expand Up @@ -187,6 +187,8 @@
{%- if compound is defined and compound -%}
{%- set element = 'legend' -%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%}
{% elseif type is defined and type == 'file' %}
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' custom-file-label')|trim}) -%}
{%- else -%}
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
{%- endif -%}
Expand Down Expand Up @@ -263,6 +265,15 @@
</{{ element|default('div') }}>
{%- endblock form_row %}

{% block file_row -%}
<div class="form-group">
<{{ element|default('div') }} class="custom-file">
{{- form_widget(form) -}}
{{- form_label(form) -}}
</{{ element|default('div') }}>
</div>
{% endblock %}

{# Errors #}

{% block form_errors -%}
Expand Down

0 comments on commit 209b32f

Please sign in to comment.