Author: adrian
Date: 2008-12-07 22:07:42 -0600 (Sun, 07 Dec 2008)
New Revision: 9592
Modified:
django/trunk/django/forms/forms.py
django/trunk/docs/topics/forms/index.txt
Log:
Edited docs/topics/forms/index.txt changes from [9569] and fixed a typo in the
visible_fields() docstring
Modified: django/trunk/django/forms/forms.py
===================================================================
--- django/trunk/django/forms/forms.py 2008-12-08 02:47:05 UTC (rev 9591)
+++ django/trunk/django/forms/forms.py 2008-12-08 04:07:42 UTC (rev 9592)
@@ -305,15 +305,15 @@
def hidden_fields(self):
"""
- Returns a list of all the BoundField objects that correspond to hidden
- fields in the HTML output. Useful for manual form layout in templates.
+ Returns a list of all the BoundField objects that are hidden fields.
+ Useful for manual form layout in templates.
"""
return [field for field in self if field.is_hidden]
def visible_fields(self):
"""
- Returns a lits of BoundField objects that do not correspond to hidden
- fields. The opposite of the hidden_fields() method.
+ Returns a list of BoundField objects that aren't hidden fields.
+ The opposite of the hidden_fields() method.
"""
return [field for field in self if not field.is_hidden]
Modified: django/trunk/docs/topics/forms/index.txt
===================================================================
--- django/trunk/docs/topics/forms/index.txt 2008-12-08 02:47:05 UTC (rev
9591)
+++ django/trunk/docs/topics/forms/index.txt 2008-12-08 04:07:42 UTC (rev
9592)
@@ -304,16 +304,17 @@
Looping over hidden and visible fields
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If you are manually laying out a form in a template, you will often want to
-work with any hidden fields in a single loop and then treat the visible fields
-differently. For example, since hidden fields don't display anything, putting
-their error messages "next to" the field isn't going to be very clear to the
-reader. So you need to handle errors for those fields a bit differently.
+If you're manually laying out a form in a template, as opposed to relying on
+Django's default form layout, you might want to treat ``<input type="hidden">``
+fields differently than non-hidden fields. For example, because hidden fields
+don't display anything, putting error messages "next to" the field could cause
+confusion for your users -- so errors for those fields should be handled
+differently.
Django provides two methods on a form that allow you to loop over the hidden
and visible fields independently: ``hidden_fields()`` and
-``visible_fields()``. In a template, you might use these like this (this is a
-modification of an earlier example)::
+``visible_fields()``. Here's a modification of an earlier example that uses
+these two methods::
<form action="/contact/" method="POST">
{% for field in form.visible_fields %}
@@ -336,7 +337,7 @@
This example does not handle any errors in the hidden fields. Usually, an
error in a hidden field is a sign of form tampering, since normal form
interaction won't alter them. However, you could easily insert some error
-displays for those form errors as well.
+displays for those form errors, as well.
.. versionadded:: 1.1
The ``hidden_fields`` and ``visible_fields`` methods are new in Django
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---