diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-01-28 22:10:04 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-01-28 22:10:04 +0000 |
| commit | cf75fcc8321b822cb4758d167f1fade56a60ad4f (patch) | |
| tree | 24dc3f666be981c609ce9ec9431d6d300214bc8c /docs | |
| parent | 83768bf067e84187780fbc749295d23bc048939b (diff) | |
Fixed #3255 -- Added help_text argument to newforms Field class.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/newforms.txt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/newforms.txt b/docs/newforms.txt index aeed33752a..063f686ed5 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -739,6 +739,38 @@ validation if a particular field's value is not given. ``initial`` values are The ``widget`` argument lets you specify a ``Widget`` class to use when rendering this ``Field``. See _`Widgets` below for more information. +``help_text`` +~~~~~~~~~~~~~ + +The ``help_text`` argument lets you specify descriptive text for this +``Field``. If you provide ``help_text``, it will be displayed next to the +``Field`` when the ``Field`` is rendered in a ``Form``. + +Here's a full example ``Form`` that implements ``help_text`` for two of its +fields. We've specified ``auto_id=False`` to simplify the output:: + + >>> class HelpTextContactForm(forms.Form): + ... subject = forms.CharField(max_length=100, help_text='100 characters max.') + ... message = forms.CharField() + ... sender = forms.EmailField(help_text='A valid e-mail address, please.') + ... cc_myself = forms.BooleanField() + >>> f = HelpTextContactForm(auto_id=False) + >>> print f.as_table() + <tr><th>Subject:</th><td><input type="text" name="subject" maxlength="100" /><br />100 characters max.</td></tr> + <tr><th>Message:</th><td><input type="text" name="message" /></td></tr> + <tr><th>Sender:</th><td><input type="text" name="sender" /><br />A valid e-mail address, please.</td></tr> + <tr><th>Cc myself:</th><td><input type="checkbox" name="cc_myself" /></td></tr> + >>> print f.as_ul() + <li>Subject: <input type="text" name="subject" maxlength="100" /> 100 characters max.</li> + <li>Message: <input type="text" name="message" /></li> + <li>Sender: <input type="text" name="sender" /> A valid e-mail address, please.</li> + <li>Cc myself: <input type="checkbox" name="cc_myself" /></li> + >>> print f.as_p() + <p>Subject: <input type="text" name="subject" maxlength="100" /> 100 characters max.</p> + <p>Message: <input type="text" name="message" /></p> + <p>Sender: <input type="text" name="sender" /> A valid e-mail address, please.</p> + <p>Cc myself: <input type="checkbox" name="cc_myself" /></p> + Dynamic initial values ---------------------- |
