From cf75fcc8321b822cb4758d167f1fade56a60ad4f Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sun, 28 Jan 2007 22:10:04 +0000 Subject: 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 --- docs/newforms.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'docs') 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() + Subject:
100 characters max. + Message: + Sender:
A valid e-mail address, please. + Cc myself: + >>> print f.as_ul() +
  • Subject: 100 characters max.
  • +
  • Message:
  • +
  • Sender: A valid e-mail address, please.
  • +
  • Cc myself:
  • + >>> print f.as_p() +

    Subject: 100 characters max.

    +

    Message:

    +

    Sender: A valid e-mail address, please.

    +

    Cc myself:

    + Dynamic initial values ---------------------- -- cgit v1.3