diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-09-16 04:38:20 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-09-16 04:38:20 +0000 |
| commit | 748e55b1daa1260964d9ec29f50e01b4b4c0f5d8 (patch) | |
| tree | 8c8fa2f21d7795b7edb909bd48a0e73235de885b /tests | |
| parent | 23f95c9dfa5ffd4ea5a11cf8797d03486d0eb6f5 (diff) | |
Fixed #4975 -- Allow the default label suffix character to be configured. Thanks, Vincent Foley.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6352 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/forms/tests.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 72033a4e60..a3e61c8f06 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -2943,6 +2943,37 @@ is default behavior. <li><label for="id_username">Username:</label> <input id="id_username" type="text" name="username" maxlength="10" /></li> <li><label for="id_password">Password:</label> <input type="password" name="password" id="id_password" /></li> + +# Label Suffix ################################################################ + +You can specify the 'label_suffix' argument to a Form class to modify the +punctuation symbol used at the end of a label. By default, the colon (:) is +used, and is only appended to the label if the label doesn't already end with a +punctuation symbol: ., !, ? or :. If you specify a different suffix, it will +be appended regardless of the last character of the label. + +>>> class FavoriteForm(Form): +... color = CharField(label='Favorite color?') +... animal = CharField(label='Favorite animal') +... +>>> f = FavoriteForm(auto_id=False) +>>> print f.as_ul() +<li>Favorite color? <input type="text" name="color" /></li> +<li>Favorite animal: <input type="text" name="animal" /></li> +>>> f = FavoriteForm(auto_id=False, label_suffix='?') +>>> print f.as_ul() +<li>Favorite color? <input type="text" name="color" /></li> +<li>Favorite animal? <input type="text" name="animal" /></li> +>>> f = FavoriteForm(auto_id=False, label_suffix='') +>>> print f.as_ul() +<li>Favorite color? <input type="text" name="color" /></li> +<li>Favorite animal <input type="text" name="animal" /></li> +>>> f = FavoriteForm(auto_id=False, label_suffix=u'\u2192') +>>> f.as_ul() +u'<li>Favorite color? <input type="text" name="color" /></li>\n<li>Favorite animal\u2192 <input type="text" name="animal" /></li>' + + + # Initial data ################################################################ You can specify initial data for a field by using the 'initial' argument to a |
