Fixed #11776 -- Added CSS class for non-field/top of form errors.

Thanks Daniel Pope for the suggestion.
This commit is contained in:
Nick Presta 2014-04-14 23:58:51 -04:00 committed by Tim Graham
parent a00efa30d6
commit 11f0899bbe
10 changed files with 120 additions and 17 deletions

View file

@ -129,6 +129,10 @@ Forms
the ``<label>`` tags for required fields will have this class present in its
attributes.
* The rendering of non-field errors in unordered lists (``<ul>``) now includes
``nonfield`` in its list of classes to distinguish them from field-specific
errors.
* :class:`~django.forms.Field` now accepts a
:attr:`~django.forms.Field.label_suffix` argument, which will override the
form's :attr:`~django.forms.Form.label_suffix`. This enables customizing the

View file

@ -292,6 +292,17 @@ over them::
</ol>
{% endif %}
.. versionchanged:: 1.8
Non-field errors (and/or hidden field errors that are rendered at the top of
the form when using helpers like ``form.as_p()``) will be rendered with an
additional class of ``nonfield`` to help distinguish them from field-specific
errors. For example, ``{{ form.non_field_errors }}`` would look like::
<ul class="errorlist nonfield">
<li>Generic validation error</li>
</ul>
Looping over the form's fields
------------------------------