Skip to content

Commit

Permalink
get validation to work for bootstrap 4
Browse files Browse the repository at this point in the history
  • Loading branch information
rakelkar committed May 28, 2018
1 parent 7a80a03 commit d2905d1
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions flask_bootstrap/templates/bootstrap/wtf.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{%- if bootstrap_is_hidden_field(form[fieldname]) and hiddens or
not bootstrap_is_hidden_field(form[fieldname]) and hiddens != 'only' %}
{%- for error in errors %}
<div class="invalid-feedback">{{error}}</div>
<div class="invalid-feedback d-block">{{error}}</div>
{%- endfor %}
{%- endif %}
{%- endfor %}
Expand Down Expand Up @@ -108,7 +108,7 @@
{%- if field.errors %}
{%- for error in field.errors %}
{% call _hz_form_wrap(horizontal_columns, form_type, required=required) %}
<div class="invalid-feedback">{{error}}</div>
<div class="invalid-feedback d-block">{{error}}</div>
{% endcall %}
{%- endfor %}
{%- elif field.description -%}
Expand All @@ -118,15 +118,23 @@
{%- endif %}
{%- else -%}
{{field.label(class="form-control-label")|safe}}
{% if field.type == 'FileField' %}
{{field(class="form-control-file", **kwargs)|safe}}
{%- if field.errors %}
{% if field.type == 'FileField' %}
{{field(class="form-control-file is-invalid", **kwargs)|safe}}
{% else %}
{{field(class="form-control is-invalid", **kwargs)|safe}}
{% endif %}
{% else %}
{{field(class="form-control", **kwargs)|safe}}
{% if field.type == 'FileField' %}
{{field(class="form-control-file", **kwargs)|safe}}
{% else %}
{{field(class="form-control", **kwargs)|safe}}
{% endif %}
{% endif %}

{%- if field.errors %}
{%- for error in field.errors %}
<div class="invalid-feedback">{{error}}</div>
<div class="invalid-feedback d-block">{{error}}</div>
{%- endfor %}
{%- elif field.description -%}
<small class="form-text text-muted">{{field.description|safe}}</small>
Expand Down

0 comments on commit d2905d1

Please sign in to comment.