diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-02-21 03:47:03 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-02-21 03:47:03 +0000 |
| commit | 5bec651a61ac9ba2831850104060833b37403399 (patch) | |
| tree | d5a077d94a9fff9223340e0d7567f5845e73e14e /tests/regressiontests/forms/tests.py | |
| parent | 97256bc39cb07b60afd08f799d31282b0813469a (diff) | |
Added small newforms unit test
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4551 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/tests.py')
| -rw-r--r-- | tests/regressiontests/forms/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 4183002809..7b5aa136e8 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -2011,6 +2011,19 @@ For a form with a <select>, use ChoiceField: <option value="J">Java</option> </select> +A subtlety: If one of the choices' value is the empty string and the form is +unbound, then the <option> for the empty-string choice will get selected="selected". +>>> class FrameworkForm(Form): +... name = CharField() +... language = ChoiceField(choices=[('', '------'), ('P', 'Python'), ('J', 'Java')]) +>>> f = FrameworkForm(auto_id=False) +>>> print f['language'] +<select name="language"> +<option value="" selected="selected">------</option> +<option value="P">Python</option> +<option value="J">Java</option> +</select> + You can specify widget attributes in the Widget constructor. >>> class FrameworkForm(Form): ... name = CharField() |
