diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-11-26 18:44:58 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-11-26 18:44:58 +0000 |
| commit | 4a14f2e23350aaf33de7f830b644a47a06100a1b (patch) | |
| tree | 58e7fc5c2f3e2e110be5764244149424ed1e9ccf /tests/regressiontests/forms/tests.py | |
| parent | 95d19384c06d3e6d5e71774d4a63a967b9f25331 (diff) | |
Fixed #3065 -- newforms: Fixed rendering problem with RadioSelect as a member of a Form. Also fixed some Unicode issues and added unit tests. Thanks for reporting, Derek Hoy
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4106 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/tests.py')
| -rw-r--r-- | tests/regressiontests/forms/tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 73fa3c27bf..0ef3e810fc 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -955,6 +955,13 @@ u'' <tr><td>Last name:</td><td><input type="text" name="last_name" value="Lennon" /></td></tr> <tr><td>Birthday:</td><td><input type="text" name="birthday" value="1940-10-9" /></td></tr> +Unicode values are handled properly. +>>> p = Person({'first_name': u'John', 'last_name': u'\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111'}) +>>> p.as_table() +u'<tr><td>First name:</td><td><input type="text" name="first_name" value="John" /></td></tr>\n<tr><td>Last name:</td><td><input type="text" name="last_name" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" /></td></tr>\n<tr><td>Birthday:</td><td><input type="text" name="birthday" /></td></tr>' +>>> p.as_ul() +u'<li>First name: <input type="text" name="first_name" value="John" /></li>\n<li>Last name: <input type="text" name="last_name" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" /></li>\n<li>Birthday: <input type="text" name="birthday" /></li>' + >>> p = Person({'last_name': u'Lennon'}) >>> p.errors() {'first_name': [u'This field is required.'], 'birthday': [u'This field is required.']} @@ -1095,6 +1102,16 @@ For a form with a <select>, use ChoiceField: <option value="J">Java</option> </select> +>>> class FrameworkForm(Form): +... name = CharField() +... language = ChoiceField(choices=[('P', 'Python'), ('J', 'Java')], widget=RadioSelect) +>>> f = FrameworkForm() +>>> print f['language'] +<ul> +<li><label><input type="radio" name="language" value="P" /> Python</label></li> +<li><label><input type="radio" name="language" value="J" /> Java</label></li> +</ul> + MultipleChoiceField is a special case, as its data is required to be a list: >>> class SongForm(Form): ... name = CharField() |
