diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
index 9fe50f5bcb8465923d69cc6ba145f44f8f55a135..59eff8a15d7530a9e418108bf71b5c1db705478a 100644
--- a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
@@ -63,6 +63,13 @@
url = list_gadget[i].getAttribute("data-gadget-url");
key = list_gadget[i].getAttribute("data-gadget-editable");
value = list_gadget[i].getAttribute("data-gadget-value");
+ if (value === null)
+ try {
+ value = JSON.parse(list_gadget[i].getAttribute("data-gadget-json"));
+ } catch(e) {
+ console.log(e); /* same remark as below (when render() fails) */
+ continue;
+ }
//renderable
if (url !== undefined && url !== null) {
tmp = {};
diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.xml
index 55d80b52809806a2a37fb4a047f2d25a355229a3..3a4d619034f2ede2ccbf9f1f201853ec1fdc9596 100644
--- a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.xml
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.xml
@@ -12,7 +12,7 @@
-
_EtagSupport__etag
- ts64799067.07
+ ts64810256.53
-
__name__
@@ -28,7 +28,7 @@
-
size
- 7383
+ 7642
-
title
diff --git a/product/ERP5Form/GadgetField.py b/product/ERP5Form/GadgetField.py
index 9167ad6243a92f50984fc134ea268e8b4281d9be..66d931e8fba220f523cd802de7e39c51207fed88 100644
--- a/product/ERP5Form/GadgetField.py
+++ b/product/ERP5Form/GadgetField.py
@@ -4,6 +4,7 @@ from Products.Formulator.DummyField import fields
from Products.Formulator import Validator
from zLOG import LOG, ERROR
from cStringIO import StringIO
+from json import dumps
class GadgetWidget(Widget.Widget):
"""
@@ -11,9 +12,16 @@ class GadgetWidget(Widget.Widget):
"""
property_names = Widget.Widget.property_names + \
['gadget_url', 'js_sandbox', 'extra']
+ property_names.insert(property_names.index('default') + 1, 'json_value')
default = Widget.TextWidget.default
+ json_value = fields.CheckBoxField('json_value',
+ title='JSON Value',
+ description='Serialize value to JSON.',
+ default=0,
+ required=0)
+
gadget_url = fields.StringField('gadget_url',
title='Gadget Url',
description=("The url of the html page containing the \
@@ -34,8 +42,11 @@ class GadgetWidget(Widget.Widget):
kw = {
'data-gadget-sandbox': field.get_value('js_sandbox'),
'data-gadget-url': field.get_value('gadget_url'),
- 'data-gadget-value': value,
}
+ if field.get_value('json_value'):
+ kw['data-gadget-json'] = dumps(value)
+ else:
+ kw['data-gadget-value'] = value
if key is not None:
kw['data-gadget-editable'] = key
return Widget.render_element("div", extra=field.get_value('extra'), **kw)