summaryrefslogtreecommitdiff
path: root/docs/ref/forms/api.txt
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@gmail.com>2014-03-23 01:08:04 +0700
committerTim Graham <timograham@gmail.com>2014-03-24 07:21:32 -0400
commit7ac8380799eedb374621317b62ccf026d86ea245 (patch)
tree45f289c8ed60df14ce6ca2312f6ad5232b85480e /docs/ref/forms/api.txt
parent3f7615cddc69235d466fb680fb05869f2a80d1e4 (diff)
Fixed #22318 -- Added Form.has_error() to easily check if a given error has happened.
Diffstat (limited to 'docs/ref/forms/api.txt')
-rw-r--r--docs/ref/forms/api.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
index c4d0b18b0f..cb6cf7a51b 100644
--- a/docs/ref/forms/api.txt
+++ b/docs/ref/forms/api.txt
@@ -182,6 +182,17 @@ when defining form errors.
Note that ``Form.add_error()`` automatically removes the relevant field from
``cleaned_data``.
+.. method:: Form.has_error(field, code=None)
+
+.. versionadded:: 1.8
+
+This method returns a boolean designating whether a field has an error with
+a specific error ``code``. If ``code`` is ``None``, it will return ``True``
+if the field contains any errors at all.
+
+To check for non-field errors use
+:data:`~django.core.exceptions.NON_FIELD_ERRORS` as the ``field`` parameter.
+
Behavior of unbound forms
~~~~~~~~~~~~~~~~~~~~~~~~~