insert an optgroup as separator on None values tls-sprint
authorsylvain.thenault@logilab.fr
Fri, 10 Apr 2009 16:48:03 +0200
branchtls-sprint
changeset 1336 2e552353c42a
parent 1335 1ad1a174da77
child 1337 828bbf500bcc
insert an optgroup as separator on None values
web/formwidgets.py
--- a/web/formwidgets.py	Fri Apr 10 16:47:15 2009 +0200
+++ b/web/formwidgets.py	Fri Apr 10 16:48:03 2009 +0200
@@ -167,7 +167,10 @@
         name, curvalues, attrs = self._render_attrs(form, field)
         options = []
         for label, value in field.vocabulary(form):
-            if value in curvalues:
+            if value is None:
+                # handle separator
+                options.append(u'<optgroup label="%s"/>' % (label or ''))
+            elif value in curvalues:
                 options.append(tags.option(label, value=value, selected='selected'))
             else:
                 options.append(tags.option(label, value=value))