nicer checkbox widget implementation, avoid extra <br/> at the end
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 27 Jul 2009 18:40:29 +0200
changeset 2519 ac1a869e1e93
parent 2518 38c28ee40138
child 2520 8c5cf48ae9ea
nicer checkbox widget implementation, avoid extra <br/> at the end
web/formwidgets.py
--- a/web/formwidgets.py	Mon Jul 27 18:39:29 2009 +0200
+++ b/web/formwidgets.py	Mon Jul 27 18:40:29 2009 +0200
@@ -224,7 +224,7 @@
     def render(self, form, field):
         name, curvalues, attrs = self._render_attrs(form, field)
         domid = attrs.pop('id', None)
-        sep = attrs.pop('separator', u'<br/>')
+        sep = attrs.pop('separator', u'<br/>\n')
         options = []
         for i, option in enumerate(field.vocabulary(form)):
             try:
@@ -239,8 +239,8 @@
             if value in curvalues:
                 iattrs['checked'] = u'checked'
             tag = tags.input(name=name, type=self.type, value=value, **iattrs)
-            options.append(tag + label + sep)
-        return '\n'.join(options)
+            options.append(tag + label)
+        return sep.join(options)
 
 
 class Radio(CheckBox):