web/form.py
branchtls-sprint
changeset 1067 f37ee6855e42
parent 1064 e17d57ee8c8c
child 1068 04c745ce692e
--- a/web/form.py	Wed Mar 11 19:50:33 2009 +0100
+++ b/web/form.py	Wed Mar 11 19:51:08 2009 +0100
@@ -381,11 +381,18 @@
 class CheckBox(Input):
     type = 'checkbox'
     
-    def _render_attrs(self, form, field):
-        name, values, attrs = super(CheckBox, self)._render_attrs(form, field)
-        if values and values[0]:
-            attrs['checked'] = u'checked'
-        return name, values, attrs
+    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:
+                tag = tags.input(name=name, value=value, type=self.type,
+                                 checked='checked', **attrs)
+            else:
+                tag = tags.input(name=name, value=value, type=self.type,
+                                 **attrs)
+            options.append(tag + label)
+        return '<br/>\n'.join(options)
 
         
 class Radio(Input):