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.
This commit is contained in:
Katie Smith
2021-12-10 15:08:40 +00:00
parent e42853205c
commit 1da285cf52

View File

@@ -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