From 5400959399688ae9240e062888d3bffbbb3a579c Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 1 Oct 2025 20:09:36 +0100 Subject: [PATCH] Enhance error handling in example form by displaying non-field errors and providing a debug view for all form errors --- .../atlas/collection_case_questions.html | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/atlas/templates/atlas/collection_case_questions.html b/atlas/templates/atlas/collection_case_questions.html index e762c860..587348f2 100644 --- a/atlas/templates/atlas/collection_case_questions.html +++ b/atlas/templates/atlas/collection_case_questions.html @@ -129,6 +129,17 @@
{% csrf_token %} + {# Show example_form non-field errors first #} + {% if example_form.non_field_errors %} +
+ Errors: +
    + {% for err in example_form.non_field_errors %} +
  • {{ err }}
  • + {% endfor %} +
+
+ {% endif %} {# Render example_form fields explicitly so we can improve error UX for json_answer #} {% for field in example_form %} {% if field.name == 'json_answer' %} @@ -163,6 +174,23 @@ {% endif %} {% endfor %} + {# Debug: list all example_form.errors (field -> [errors]) in a collapsed block so nothing is missed #} + {% if example_form.errors %} +
+ All example form errors (debug) +
    + {% for name, errs in example_form.errors.items %} +
  • {{ name }} +
      + {% for e in errs %} +
    • {{ e }}
    • + {% endfor %} +
    +
  • + {% endfor %} +
+
+ {% endif %}
{% endif %}