src/pyams_thesaurus/widget/__init__.py
changeset 12 5f2f8657934b
parent 0 47700a43ef3f
child 73 6eaae503e35d
--- a/src/pyams_thesaurus/widget/__init__.py	Wed Jul 22 17:22:01 2015 +0200
+++ b/src/pyams_thesaurus/widget/__init__.py	Wed Jul 22 17:23:33 2015 +0200
@@ -135,7 +135,8 @@
                 thesaurus = query_utility(IThesaurus, name=thesaurus_name)
         if thesaurus is None:
             return None
-        value = value.split('|')
+        if isinstance(value, str):
+            value = value.split('|')
         for idx, val in enumerate(value):
             match = SYNONYM.match(val)
             if match:
@@ -169,3 +170,17 @@
 def ThesaurusTermsListFieldWidget(field, request):
     """Thesaurus terms list field widget factory"""
     return FieldWidget(field, ThesaurusTermsListWidget(request))
+
+
+#
+# Terms list widget with selector
+#
+
+@widgettemplate_config(mode='input', template='templates/terms-list-selector-input.pt', layer=IFormLayer)
+class ThesaurusTermsListSelectorWidget(ThesaurusTermsListWidget):
+    """Thesaurus terms list widget with selector"""
+
+
+def ThesaurusTermsListSelectorFieldWidget(field, request):
+    """Thesaurus terms list field widget with selector factory"""
+    return FieldWidget(field, ThesaurusTermsListSelectorWidget(request))