Edited forms/index.txt changes from [9030]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9040 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2008-09-16 05:22:08 +00:00
parent f09f744f81
commit fdd3cb4930
1 changed files with 28 additions and 26 deletions

View File

@ -253,9 +253,9 @@ over them::
Looping over the form's fields Looping over the form's fields
------------------------------ ------------------------------
If you are using the similar HTML for each of your form fields, you can If you're the same HTML for each of your form fields, you can
reduce duplicate code by looping through each field in turn using reduce duplicate code by looping through each field in turn using
``{% for field in form %}``:: a ``{% for %}`` loop::
<form action="/contact/" method="POST"> <form action="/contact/" method="POST">
{% for field in form %} {% for field in form %}
@ -268,19 +268,19 @@ reduce duplicate code by looping through each field in turn using
</form> </form>
Within this loop, ``{{ field }}`` is an instance of :class:`BoundField`. Within this loop, ``{{ field }}`` is an instance of :class:`BoundField`.
``BoundField`` also has the following attributes which can be useful in your ``BoundField`` also has the following attributes, which can be useful in your
templates: templates:
``{{ field.label }}`` ``{{ field.label }}``
The label of the field, e.g. ``Name``. The label of the field, e.g. ``E-mail address``.
``{{ field.label_tag }}`` ``{{ field.label_tag }}``
The field's label wrapped in the appropriate HTML ``<label>`` tag, The field's label wrapped in the appropriate HTML ``<label>`` tag,
e.g. ``<label for="id_name">Name</label>`` e.g. ``<label for="id_email">E-mail address</label>``
``{{ field.html_name }}`` ``{{ field.html_name }}``
The name of the field that will be used in the input element's name The name of the field that will be used in the input element's name
field; this takes the form prefix in to account if it has been set. field. This takes the form prefix into account, if it has been set.
``{{ field.help_text }}`` ``{{ field.help_text }}``
Any help text that has been associated with the field. Any help text that has been associated with the field.
@ -288,7 +288,9 @@ templates:
``{{ field.errors }}`` ``{{ field.errors }}``
Outputs a ``<ul class="errorlist">`` containing any validation errors Outputs a ``<ul class="errorlist">`` containing any validation errors
corresponding to this field. You can customize the presentation of corresponding to this field. You can customize the presentation of
the errors with a ``{% for error in field.errors %}`` loop. the errors with a ``{% for error in field.errors %}`` loop. In this
case, each object in the loop is a simple string containing the error
message.
Reusable form templates Reusable form templates
----------------------- -----------------------