merge tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 13 May 2009 09:13:26 +0200
branchtls-sprint
changeset 1772 21d1db460cdb
parent 1770 8bd788149f85 (current diff)
parent 1771 bb9538d91465 (diff)
child 1773 789ee507a8e0
child 1776 4be367276874
merge
--- a/web/formwidgets.py	Wed May 13 09:09:50 2009 +0200
+++ b/web/formwidgets.py	Wed May 13 09:13:26 2009 +0200
@@ -173,14 +173,20 @@
         if not 'size' in attrs and self._multiple:
             attrs['size'] = '5'
         options = []
+        optgroup_opened = False
         for label, value in field.vocabulary(form):
             if value is None:
                 # handle separator
-                options.append(u'<optgroup label="%s"/>' % (label or ''))
+                if optgroup_opened:
+                    options.append(u'</optgroup>')
+                options.append(u'<optgroup label="%s">' % (label or ''))
+                optgroup_opened = True
             elif value in curvalues:
                 options.append(tags.option(label, value=value, selected='selected'))
             else:
                 options.append(tags.option(label, value=value))
+        if optgroup_opened:
+            options.append(u'</optgroup>')
         return tags.select(name=name, multiple=self._multiple,
                            options=options, **attrs)