web/form.py
branchtls-sprint
changeset 1056 be43d95ebb52
parent 1055 b87222b63950
child 1058 c27be37daef8
--- a/web/form.py	Wed Mar 11 11:34:46 2009 +0100
+++ b/web/form.py	Wed Mar 11 11:51:52 2009 +0100
@@ -369,9 +369,8 @@
         
     def render(self, form, field):
         name, curvalues, attrs = self._render_attrs(form, field)
-        vocab = field.vocabulary(form)
         options = []
-        for label, value in vocab:
+        for label, value in field.vocabulary(form):
             if value in curvalues:
                 options.append(tags.option(label, value=value, selected='selected'))
             else:
@@ -392,8 +391,20 @@
         return name, values, attrs
 
         
-class Radio(FieldWidget):
-    pass
+class Radio(Input):
+    type = 'radio'
+    setdomid = False
+    
+    def render(self, form, field):
+        name, curvalues, attrs = self._render_attrs(form, field)
+        options = []
+        for label, value in field.vocabulary(form):
+            if value in curvalues:
+                options.append(tags.input(name=name, type=self.type, value=value, checked='checked', **attrs))
+            else:
+                options.append(tags.option(name=name, type=self.type, value=value, **attrs))
+            options[-1] += label + '<br/>'
+        return '\n'.join(options)
 
 
 class DateTimePicker(TextInput):