From 2ab2b45dc412670200ee7deca30d5de1065e513c Mon Sep 17 00:00:00 2001 From: Dan Braghis <dan.braghis@torchbox.com> Date: Wed, 17 Jan 2018 11:48:44 +0000 Subject: [PATCH] Add non-field errors to the forms --- .../apply/funds/templates/funds/fund_type.html | 16 +++++++++++++++- .../forms/templates/public_forms/form_page.html | 13 +++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/opentech/apply/funds/templates/funds/fund_type.html b/opentech/apply/funds/templates/funds/fund_type.html index 9266ec9c8..8b61a7da8 100644 --- a/opentech/apply/funds/templates/funds/fund_type.html +++ b/opentech/apply/funds/templates/funds/fund_type.html @@ -1,10 +1,24 @@ {% extends "base.html" %} - {% load wagtailcore_tags %} + {% block content %} <h1>{{ page.title }}</h1> + <form action="{% pageurl page %}" method="POST"> {% csrf_token %} + + {% if form.errors or form.non_field_errors %} + <div class="messages"> + There were some errors with your form. Please amend the fields highlighted below. {% if form.non_field_errors %} + <ul> + {% for error in form.non_field_errors %} + <li class="error">{{ error }}</li> + {% endfor %} + </ul> + {% endif %} + </div> + {% endif %} + {{ form.as_p }} <input type="submit"> </form> diff --git a/opentech/public/forms/templates/public_forms/form_page.html b/opentech/public/forms/templates/public_forms/form_page.html index 566f5506b..cf64e1aec 100644 --- a/opentech/public/forms/templates/public_forms/form_page.html +++ b/opentech/public/forms/templates/public_forms/form_page.html @@ -18,8 +18,17 @@ <div> {% csrf_token %} - {% if form.errors %} - There were some errors with your form. Please amend the fields highlighted below. + {% if form.errors or form.non_field_errors %} + <div class="messages"> + There were some errors with your form. Please amend the fields highlighted below. + {% if form.non_field_errors %} + <ul> + {% for error in form.non_field_errors %} + <li class="error">{{ error }}</li> + {% endfor %} + </ul> + {% endif %} + </div> {% endif %} {% for field in form %} -- GitLab