From 0839eb7e379265c439012d488250f68d86341975 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 22 Sep 2025 12:45:32 +0100 Subject: [PATCH] Enhance error handling and user experience for JSON answer input in form --- .../atlas/collection_case_questions.html | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/atlas/templates/atlas/collection_case_questions.html b/atlas/templates/atlas/collection_case_questions.html index d16de1da..e762c860 100644 --- a/atlas/templates/atlas/collection_case_questions.html +++ b/atlas/templates/atlas/collection_case_questions.html @@ -129,7 +129,40 @@
{% csrf_token %} - {{example_form}} + {# Render example_form fields explicitly so we can improve error UX for json_answer #} + {% for field in example_form %} + {% if field.name == 'json_answer' %} +
+ {% if field.errors %} + + {% endif %} + {{ field }} {# hidden/JS-bound field stays rendered #} +
+ {% else %} +
+ {{ field.label_tag }} {{ field }} + {% if field.errors %} + {% for err in field.errors %} +
{{ err }}
+ {% endfor %} + {% endif %} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} +
+ {% endif %} + {% endfor %}
{% endif %}