From 1da285cf520a2627810868f13dcc8f95c8b12a10 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Fri, 10 Dec 2021 15:08:40 +0000 Subject: [PATCH] Only show one error for radio field and check boxes We don't currently have any radio fields or check boxes where it's possible to get more than one validation error. However, since we never want to show more than one error at a time for a field, this changes the error messages for the relevant widgets to only show the first error if there ever were multiple. --- app/main/forms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index f8ed35e1c..3b05c7b9e 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -657,7 +657,7 @@ def govuk_checkbox_field_widget(self, field, param_extensions=None, **kwargs): "data-error-type": field.errors[0], "data-error-label": field.name }, - "text": " ".join(field.errors).strip() + "text": field.errors[0] } params = { @@ -710,7 +710,7 @@ def govuk_checkboxes_field_widget(self, field, wrap_in_collapsible=False, param_ "data-error-type": field.errors[0], "data-error-label": field.name }, - "text": " ".join(field.errors).strip() + "text": field.errors[0] } # returns either a list or a hierarchy of lists @@ -765,7 +765,7 @@ def govuk_radios_field_widget(self, field, param_extensions=None, **kwargs): "data-error-type": field.errors[0], "data-error-label": field.name }, - "text": " ".join(field.errors).strip() + "text": field.errors[0] } # returns either a list or a hierarchy of lists