mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #8426 - added 'helptext' CSS class to help text in forms to aid in styling
Thanks to erikcw for report, mrts and rpbarlow for patch git-svn-id: http://code.djangoproject.com/svn/django/trunk@13519 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1258,20 +1258,20 @@ to a Field class. This help text is displayed when a Form is rendered.
|
||||
... password = CharField(widget=PasswordInput, help_text='Choose wisely.')
|
||||
>>> p = UserRegistration(auto_id=False)
|
||||
>>> print p.as_ul()
|
||||
<li>Username: <input type="text" name="username" maxlength="10" /> e.g., user@example.com</li>
|
||||
<li>Password: <input type="password" name="password" /> Choose wisely.</li>
|
||||
<li>Username: <input type="text" name="username" maxlength="10" /> <span class="helptext">e.g., user@example.com</span></li>
|
||||
<li>Password: <input type="password" name="password" /> <span class="helptext">Choose wisely.</span></li>
|
||||
>>> print p.as_p()
|
||||
<p>Username: <input type="text" name="username" maxlength="10" /> e.g., user@example.com</p>
|
||||
<p>Password: <input type="password" name="password" /> Choose wisely.</p>
|
||||
<p>Username: <input type="text" name="username" maxlength="10" /> <span class="helptext">e.g., user@example.com</span></p>
|
||||
<p>Password: <input type="password" name="password" /> <span class="helptext">Choose wisely.</span></p>
|
||||
>>> print p.as_table()
|
||||
<tr><th>Username:</th><td><input type="text" name="username" maxlength="10" /><br />e.g., user@example.com</td></tr>
|
||||
<tr><th>Password:</th><td><input type="password" name="password" /><br />Choose wisely.</td></tr>
|
||||
<tr><th>Username:</th><td><input type="text" name="username" maxlength="10" /><br /><span class="helptext">e.g., user@example.com</span></td></tr>
|
||||
<tr><th>Password:</th><td><input type="password" name="password" /><br /><span class="helptext">Choose wisely.</span></td></tr>
|
||||
|
||||
The help text is displayed whether or not data is provided for the form.
|
||||
>>> p = UserRegistration({'username': u'foo'}, auto_id=False)
|
||||
>>> print p.as_ul()
|
||||
<li>Username: <input type="text" name="username" value="foo" maxlength="10" /> e.g., user@example.com</li>
|
||||
<li><ul class="errorlist"><li>This field is required.</li></ul>Password: <input type="password" name="password" /> Choose wisely.</li>
|
||||
<li>Username: <input type="text" name="username" value="foo" maxlength="10" /> <span class="helptext">e.g., user@example.com</span></li>
|
||||
<li><ul class="errorlist"><li>This field is required.</li></ul>Password: <input type="password" name="password" /> <span class="helptext">Choose wisely.</span></li>
|
||||
|
||||
help_text is not displayed for hidden fields. It can be used for documentation
|
||||
purposes, though.
|
||||
@@ -1281,7 +1281,7 @@ purposes, though.
|
||||
... next = CharField(widget=HiddenInput, initial='/', help_text='Redirect destination')
|
||||
>>> p = UserRegistration(auto_id=False)
|
||||
>>> print p.as_ul()
|
||||
<li>Username: <input type="text" name="username" maxlength="10" /> e.g., user@example.com</li>
|
||||
<li>Username: <input type="text" name="username" maxlength="10" /> <span class="helptext">e.g., user@example.com</span></li>
|
||||
<li>Password: <input type="password" name="password" /><input type="hidden" name="next" value="/" /></li>
|
||||
|
||||
Help text can include arbitrary Unicode characters.
|
||||
@@ -1289,7 +1289,7 @@ Help text can include arbitrary Unicode characters.
|
||||
... username = CharField(max_length=10, help_text='ŠĐĆŽćžšđ')
|
||||
>>> p = UserRegistration(auto_id=False)
|
||||
>>> p.as_ul()
|
||||
u'<li>Username: <input type="text" name="username" maxlength="10" /> \u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</li>'
|
||||
u'<li>Username: <input type="text" name="username" maxlength="10" /> <span class="helptext">\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</span></li>'
|
||||
|
||||
# Subclassing forms ###########################################################
|
||||
|
||||
|
||||
Reference in New Issue
Block a user