fix CheckBox multiple dom id and refactor with Radio tls-sprint
authorFlorent <florent@secondweb.fr>
Thu, 14 May 2009 18:12:45 +0200
branchtls-sprint
changeset 1832 3384264d25cc
parent 1799 183acfaa3cde
child 1833 c50245fb9ac2
child 2022 31412adee482
fix CheckBox multiple dom id and refactor with Radio
web/formwidgets.py
--- a/web/formwidgets.py	Thu May 14 08:35:19 2009 +0200
+++ b/web/formwidgets.py	Thu May 14 18:12:45 2009 +0200
@@ -199,26 +199,6 @@
 
     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):
-    """<input type='radio'>, for field having a specific vocabulary. One
-    input will be generated for each possible value.
-    """
-    type = 'radio'
-
-    def render(self, form, field):
-        name, curvalues, attrs = self._render_attrs(form, field)
         domid = attrs.pop('id', None)
         options = []
         for i, (label, value) in enumerate(field.vocabulary(form)):
@@ -232,6 +212,12 @@
         return '\n'.join(options)
 
 
+class Radio(CheckBox):
+    """<input type='radio'>, for field having a specific vocabulary. One
+    input will be generated for each possible value.
+    """
+    type = 'radio'
+
 # javascript widgets ###########################################################
 
 class DateTimePicker(TextInput):