summaryrefslogtreecommitdiff
path: root/django/newforms
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-12-26 22:56:53 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-12-26 22:56:53 +0000
commit247fdc19ad256c7599f043aa49d3125d3a1f4356 (patch)
treea4030fb3d7f23f802fa06be59b722da89792bec7 /django/newforms
parenta5d3e0c3ef8975bfc8ab5bd4c13c27edab43b86b (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 'django/newforms')
-rw-r--r--django/newforms/widgets.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py
index 0dd0692e29..996e353775 100644
--- a/django/newforms/widgets.py
+++ b/django/newforms/widgets.py
@@ -189,6 +189,10 @@ class RadioFieldRenderer(StrAndUnicode):
for i, choice in enumerate(self.choices):
yield RadioInput(self.name, self.value, self.attrs.copy(), choice, i)
+ def __getitem__(self, idx):
+ choice = self.choices[idx] # Let the IndexError propogate
+ return RadioInput(self.name, self.value, self.attrs.copy(), choice, idx)
+
def __unicode__(self):
"Outputs a <ul> for this set of radio fields."
return u'<ul>\n%s\n</ul>' % u'\n'.join([u'<li>%s</li>' % w for w in self])