form_ errors
The error category strings for errors from a form created by a form
tag.
The following table outlines the strings that can be returned and the reason that they would be:
Form property name | Return reason |
---|---|
author | There were issues with required name fields. |
body | There were issues with required text content fields. |
email | There were issues with required email fields. |
form | There were general issues with the form. |
password | There were issues with required password fields. |
Properties
The translated error messages for each value in the
array.
You can access a specific message in the array by using a specific error from the
array as a key.
{
"messages": {},
"translated_fields": {}
}
{
"messages": {},
"translated_fields": {}
}
Anchor to Output form errors
Output form errors
You can output the name of the field related to the error, and the error message, by using the error as a key to access the and
messages
properties.
<ul>
{% for error in form.errors %}
<li>
{% if error == 'form' %}
{{ form.errors.messages[error] }}
{% else %}
{{ form.errors.translated_fields[error] }} - {{ form.errors.messages[error] }}
{% endif %}
</li>
{% endfor %}
</ul>
Was this section helpful?