diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/forms/api.txt | 11 | ||||
| -rw-r--r-- | docs/releases/1.8.txt | 3 |
2 files changed, 14 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 ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 2214b77839..10acdb6df4 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -109,6 +109,9 @@ Forms * Form widgets now render attributes with a value of ``True`` or ``False`` as HTML5 boolean attributes. +* The new :meth:`~django.forms.Form.has_error()` method allows checking + if a specific error has happened. + Internationalization ^^^^^^^^^^^^^^^^^^^^ |
