diff options
| author | Simon Willison <simon@simonwillison.net> | 2008-09-15 00:07:13 +0000 |
|---|---|---|
| committer | Simon Willison <simon@simonwillison.net> | 2008-09-15 00:07:13 +0000 |
| commit | 5389c0d2afebcee36bdef23a61788eef29374e78 (patch) | |
| tree | 5b3ff594c4bfc982e2e46c95e1e83299edc872c3 /docs/ref/forms/api.txt | |
| parent | 7ac86d17c8d1d39269a4064e9fc2e96c2fd125da (diff) | |
Added documentation of the Form class's custom __iter__ method to the forms API reference as well
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9031 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/forms/api.txt')
| -rw-r--r-- | docs/ref/forms/api.txt | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 72dfcb67c9..285d43b01c 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -530,6 +530,16 @@ string or Unicode object, respectively:: >>> unicode(f['subject']) u'<input id="id_subject" type="text" name="subject" maxlength="100" />' +Form objects define a custom ``__iter__`` method which allows you to loop +through their fields:: + + >>> f = ContactForm() + >>> for field in f: print field + <input id="id_subject" type="text" name="subject" maxlength="100" /> + <input type="text" name="message" id="id_message" /> + <input type="text" name="sender" id="id_sender" /> + <input type="checkbox" name="cc_myself" id="id_cc_myself" /> + The field-specific output honors the form object's ``auto_id`` setting:: >>> f = ContactForm(auto_id=False) |
