1
0
mirror of https://github.com/django/django.git synced 2025-10-29 08:36:09 +00:00

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
This commit is contained in:
Adrian Holovaty
2006-12-26 22:56:53 +00:00
parent a5d3e0c3ef
commit 247fdc19ad
2 changed files with 23 additions and 0 deletions

View File

@@ -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])