1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Alphabetized field attributes in form topic docs.

This commit is contained in:
David Smith 2022-01-12 07:07:21 +00:00 committed by GitHub
parent 367d6920ec
commit 75c1127eef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -640,15 +640,24 @@ loop:
Useful attributes on ``{{ field }}`` include: Useful attributes on ``{{ field }}`` include:
``{{ field.label }}`` ``{{ field.errors }}``
The label of the field, e.g. ``Email address``. Outputs a ``<ul class="errorlist">`` containing any validation errors
corresponding to this field. You can customize the presentation of
the errors with a ``{% for error in field.errors %}`` loop. In this
case, each object in the loop is a string containing the error message.
``{{ field.label_tag }}`` ``{{ field.field }}``
The field's label wrapped in the appropriate HTML ``<label>`` tag. This The :class:`~django.forms.Field` instance from the form class that
includes the form's :attr:`~django.forms.Form.label_suffix`. For example, this :class:`~django.forms.BoundField` wraps. You can use it to access
the default ``label_suffix`` is a colon:: :class:`~django.forms.Field` attributes, e.g.
``{{ char_field.field.max_length }}``.
<label for="id_email">Email address:</label> ``{{ field.help_text }}``
Any help text that has been associated with the field.
``{{ field.html_name }}``
The name of the field that will be used in the input element's name
field. This takes the form prefix into account, if it has been set.
``{{ field.id_for_label }}`` ``{{ field.id_for_label }}``
The ID that will be used for this field (``id_email`` in the example The ID that will be used for this field (``id_email`` in the example
@ -656,22 +665,6 @@ Useful attributes on ``{{ field }}`` include:
this in lieu of ``label_tag``. It's also useful, for example, if you have this in lieu of ``label_tag``. It's also useful, for example, if you have
some inline JavaScript and want to avoid hardcoding the field's ID. some inline JavaScript and want to avoid hardcoding the field's ID.
``{{ field.value }}``
The value of the field. e.g ``someone@example.com``.
``{{ field.html_name }}``
The name of the field that will be used in the input element's name
field. This takes the form prefix into account, if it has been set.
``{{ field.help_text }}``
Any help text that has been associated with the field.
``{{ field.errors }}``
Outputs a ``<ul class="errorlist">`` containing any validation errors
corresponding to this field. You can customize the presentation of
the errors with a ``{% for error in field.errors %}`` loop. In this
case, each object in the loop is a string containing the error message.
``{{ field.is_hidden }}`` ``{{ field.is_hidden }}``
This attribute is ``True`` if the form field is a hidden field and This attribute is ``True`` if the form field is a hidden field and
``False`` otherwise. It's not particularly useful as a template ``False`` otherwise. It's not particularly useful as a template
@ -683,11 +676,18 @@ Useful attributes on ``{{ field }}`` include:
{# Do something special #} {# Do something special #}
{% endif %} {% endif %}
``{{ field.field }}`` ``{{ field.label }}``
The :class:`~django.forms.Field` instance from the form class that The label of the field, e.g. ``Email address``.
this :class:`~django.forms.BoundField` wraps. You can use it to access
:class:`~django.forms.Field` attributes, e.g. ``{{ field.label_tag }}``
``{{ char_field.field.max_length }}``. The field's label wrapped in the appropriate HTML ``<label>`` tag. This
includes the form's :attr:`~django.forms.Form.label_suffix`. For example,
the default ``label_suffix`` is a colon::
<label for="id_email">Email address:</label>
``{{ field.value }}``
The value of the field. e.g ``someone@example.com``.
.. seealso:: .. seealso::