From 748e55b1daa1260964d9ec29f50e01b4b4c0f5d8 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sun, 16 Sep 2007 04:38:20 +0000 Subject: 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 --- tests/regressiontests/forms/tests.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/regressiontests/forms') 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.
  • + +# 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() +
  • Favorite color?
  • +
  • Favorite animal:
  • +>>> f = FavoriteForm(auto_id=False, label_suffix='?') +>>> print f.as_ul() +
  • Favorite color?
  • +
  • Favorite animal?
  • +>>> f = FavoriteForm(auto_id=False, label_suffix='') +>>> print f.as_ul() +
  • Favorite color?
  • +
  • Favorite animal
  • +>>> f = FavoriteForm(auto_id=False, label_suffix=u'\u2192') +>>> f.as_ul() +u'
  • Favorite color?
  • \n
  • Favorite animal\u2192
  • ' + + + # Initial data ################################################################ You can specify initial data for a field by using the 'initial' argument to a -- cgit v1.3