From 247fdc19ad256c7599f043aa49d3125d3a1f4356 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 26 Dec 2006 22:56:53 +0000 Subject: 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 --- tests/regressiontests/forms/tests.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') 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] + +>>> print r[0] + +>>> 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() -- cgit v1.3