utils: improve error message when form field validation fails

This commit is contained in:
Baptiste Jonglez 2024-03-29 18:44:27 +01:00 committed by Alexis Métaireau
parent 9a834c97e3
commit 967266f7dc
No known key found for this signature in database
GPG key ID: 1C21B876828E5FF2

View file

@ -452,7 +452,9 @@ def format_form_errors(form, prefix):
)
else:
error_list = "</li><li>".join(
str(error) for (field, errors) in form.errors.items() for error in errors
f"<strong>{field}</strong> {error}"
for (field, errors) in form.errors.items()
for error in errors
)
errors = f"<ul><li>{error_list}</li></ul>"
# I18N: Form error with a list of errors