Skip to content

Commit

Permalink
Merge pull request #321 from sampart/docs/displaying-form-errors
Browse files Browse the repository at this point in the history
Add to docs with example of validation errors in templates
  • Loading branch information
azmeuk authored Jul 28, 2020
2 parents a8f92a5 + cae7fbb commit 76413ae
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,18 @@ Note that you don't have to pass ``request.form`` to Flask-WTF; it will
load automatically. And the convenient ``validate_on_submit`` will check
if it is a POST request and if it is valid.

If your forms include validation, you'll need to add to your template to display
any error messages. Using the ``form.name`` field from the example above, that
would look like this:

.. sourcecode:: html+jinja

{% if form.name.errors %}
<ul class="errors">
{% for error in form.name %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}

Heading over to :doc:`form` to learn more skills.

0 comments on commit 76413ae

Please sign in to comment.