diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-12-26 22:56:53 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-12-26 22:56:53 +0000 |
| commit | 247fdc19ad256c7599f043aa49d3125d3a1f4356 (patch) | |
| tree | a4030fb3d7f23f802fa06be59b722da89792bec7 /tests/regressiontests/forms/tests.py | |
| parent | a5d3e0c3ef8975bfc8ab5bd4c13c27edab43b86b (diff) | |
newforms: Implemented RadioFieldRenderer.__getitem__(), which allows for index lookup on radio fields
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4238 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/tests.py')
| -rw-r--r-- | tests/regressiontests/forms/tests.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index a3445d7176..6bf64422fb 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -514,6 +514,25 @@ beatle J P Paul False beatle J G George False beatle J R Ringo False +A RadioFieldRenderer object also allows index access to individual RadioInput +objects. +>>> w = RadioSelect() +>>> r = w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))) +>>> print r[1] +<label><input type="radio" name="beatle" value="P" /> Paul</label> +>>> print r[0] +<label><input checked="checked" type="radio" name="beatle" value="J" /> John</label> +>>> r[0].is_checked() +True +>>> r[1].is_checked() +False +>>> r[1].name, r[1].value, r[1].choice_value, r[1].choice_label +('beatle', u'J', 'P', 'Paul') +>>> r[10] +Traceback (most recent call last): +... +IndexError: list index out of range + # CheckboxSelectMultiple Widget ############################################### >>> w = CheckboxSelectMultiple() |
