diff -r fd5bd1a63c3f -r 01bb5b727fe3 web/formwidgets.py
--- a/web/formwidgets.py Wed Apr 15 17:24:12 2009 +0200
+++ b/web/formwidgets.py Wed Apr 15 17:24:34 2009 +0200
@@ -203,19 +203,19 @@
input will be generated for each possible value.
"""
type = 'radio'
- setdomid = False # by default, don't set id attribute on radio input
def render(self, form, field):
name, curvalues, attrs = self._render_attrs(form, field)
+ domid = attrs.pop('id', None)
options = []
- for label, value in field.vocabulary(form):
+ for i, (label, value) in enumerate(field.vocabulary(form)):
+ iattrs = attrs.copy()
+ if i == 0 and domid is not None:
+ iattrs['id'] = domid
if value in curvalues:
- tag = tags.input(name=name, type=self.type, value=value,
- checked='checked', **attrs)
- else:
- tag = tags.input(name=name, type=self.type, value=value, **attrs)
- tag += label + '
'
- options.append(tag)
+ iattrs['checked'] = u'checked'
+ tag = tags.input(name=name, type=self.type, value=value, **iattrs)
+ options.append(tag + label + '
')
return '\n'.join(options)