Skip to content

Commit

Permalink
[Form] Add Bootstrap 4 style for field FileType
Browse files Browse the repository at this point in the history
  • Loading branch information
zenmate authored and fabpot committed Mar 27, 2018
1 parent 9e82562 commit df57718
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 @@ -257,6 +259,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 df57718

Please sign in to comment.