Updated hidden Select2 widget data extraction
authorThierry Florac <tflorac@ulthar.net>
Wed, 13 Jan 2021 14:06:19 +0100
changeset 220 08755669300a
parent 219 8072c47cdecd
child 221 21453aabc61f
Updated hidden Select2 widget data extraction
src/pyams_form/widget/__init__.py
--- a/src/pyams_form/widget/__init__.py	Wed Jan 13 14:06:00 2021 +0100
+++ b/src/pyams_form/widget/__init__.py	Wed Jan 13 14:06:19 2021 +0100
@@ -46,19 +46,19 @@
 from zope.interface import Interface, directlyProvides, implementer, implementer_only
 from zope.pagetemplate.interfaces import IPageTemplate
 from zope.schema.fieldproperty import FieldProperty
-from zope.schema.interfaces import IBytes, IChoice, IDate, IDatetime, IFloat, IInt, IList, ISet, \
-    ITime, ITuple, IDecimal
+from zope.schema.interfaces import IBytes, IChoice, IDate, IDatetime, IDecimal, IFloat, IInt, \
+    IList, ISet, ITime, ITuple
 
 from pyams_form.interfaces.form import IActionWidget, ICloseWidget, IColorWidget, IDateWidget, \
-    IDatetimeWidget, IFloatWidget, IFormLayer, IHTMLWidget, IIntegerWidget, IJSONDictWidget, \
-    IResetWidget, ISEOTextLineWidget, ISelect2Widget, ITextLineListWidget, ITimeWidget, \
-    IDottedDecimalWidget
+    IDatetimeWidget, IDottedDecimalWidget, IFloatWidget, IFormLayer, IHTMLWidget, IIntegerWidget, \
+    IJSONDictWidget, IResetWidget, ISEOTextLineWidget, ISelect2Widget, ITextLineListWidget, \
+    ITimeWidget
 from pyams_form.schema import IActionButton, ICloseButton, IResetButton
 from pyams_skin.interfaces.tinymce import ITinyMCEConfiguration
 from pyams_utils.adapter import adapter_config
 from pyams_utils.interfaces.data import IObjectData
-from pyams_utils.schema import IColorField, IHTMLField, IJSONDictField, ITextLineListField, \
-    IJSONDictFieldsGetter, IDottedDecimalField, DottedDecimalField
+from pyams_utils.schema import IColorField, IDottedDecimalField, IHTMLField, IJSONDictField, \
+    IJSONDictFieldsGetter, ITextLineListField
 from pyams_utils.timezone import localgmtime, tztime
 from pyams_utils.widget.decimal import DottedDecimalDataConverter
 
@@ -720,7 +720,7 @@
         value = self.request.get(self.name, default)
         if value != default:
             if not isinstance(value, (set, tuple, list)):
-                value = set(value.split('|'))
+                value = set(value.split('|')) if value else set()
             # do some kind of validation, at least only use existing values
             for token in value:
                 if token == self.noValueToken: