From d2905d1b3271519bc853fffff1be835f22e68df6 Mon Sep 17 00:00:00 2001 From: Rakesh Kelkar Date: Mon, 28 May 2018 04:14:10 -0700 Subject: [PATCH] get validation to work for bootstrap 4 --- flask_bootstrap/templates/bootstrap/wtf.html | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/flask_bootstrap/templates/bootstrap/wtf.html b/flask_bootstrap/templates/bootstrap/wtf.html index 18192006..0b894240 100644 --- a/flask_bootstrap/templates/bootstrap/wtf.html +++ b/flask_bootstrap/templates/bootstrap/wtf.html @@ -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 %} -
{{error}}
+
{{error}}
{%- endfor %} {%- endif %} {%- endfor %} @@ -108,7 +108,7 @@ {%- if field.errors %} {%- for error in field.errors %} {% call _hz_form_wrap(horizontal_columns, form_type, required=required) %} -
{{error}}
+
{{error}}
{% endcall %} {%- endfor %} {%- elif field.description -%} @@ -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 %} -
{{error}}
+
{{error}}
{%- endfor %} {%- elif field.description -%} {{field.description|safe}}