mirror of https://github.com/django/django.git
[1.5.x] Documented BoundField.label_tag
Backport of 0f99246b6
from master.
This commit is contained in:
parent
709ee83cd3
commit
991432ee8a
|
@ -638,6 +638,19 @@ For a field's list of errors, access the field's ``errors`` attribute.
|
||||||
>>> str(f['subject'].errors)
|
>>> str(f['subject'].errors)
|
||||||
''
|
''
|
||||||
|
|
||||||
|
.. method:: BoundField.label_tag(contents=None, attrs=None)
|
||||||
|
|
||||||
|
To separately render the label tag of a form field, you can call its
|
||||||
|
``label_tag`` method::
|
||||||
|
|
||||||
|
>>> f = ContactForm(data)
|
||||||
|
>>> print(f['message'].label_tag())
|
||||||
|
<label for="id_message">Message</label>
|
||||||
|
|
||||||
|
Optionally, you can provide the ``contents`` parameter which will replace the
|
||||||
|
auto-generated label tag. An optional ``attrs`` dictionary may contain
|
||||||
|
additional attributes for the ``<label>`` tag.
|
||||||
|
|
||||||
.. method:: BoundField.css_classes()
|
.. method:: BoundField.css_classes()
|
||||||
|
|
||||||
When you use Django's rendering shortcuts, CSS classes are used to
|
When you use Django's rendering shortcuts, CSS classes are used to
|
||||||
|
|
Loading…
Reference in New Issue