# HG changeset patch # User Florent # Date 1242197912 -7200 # Node ID bb9538d914651acfff4140b5083fe7f4ac7e7337 # Parent b59b7c422a8a7714cf0fe646523cd10168df2bc4 fix tag cannot be empty according to DTD diff -r b59b7c422a8a -r bb9538d91465 web/formwidgets.py --- a/web/formwidgets.py Wed May 13 08:41:23 2009 +0200 +++ b/web/formwidgets.py Wed May 13 08:58:32 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'' % (label or '')) + if optgroup_opened: + options.append(u'') + options.append(u'' % (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'') return tags.select(name=name, multiple=self._multiple, options=options, **attrs)