Commit 211b58f5 authored by Tatuya Kamada's avatar Tatuya Kamada

Formulator: Add gadget_url_js field into TextWidget to customise renderjs gadget

parent 21cd9c2f
...@@ -118,6 +118,13 @@ class Widget: ...@@ -118,6 +118,13 @@ class Widget:
default="", default="",
required=0) required=0)
gadget_url_js = fields.StringField('gadget_url_js',
title='Gadget javascript URL',
description=(
"A url specifying the customised gadget javascript in renderjs_ui."),
default="",
required=0)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST):
"""Renders this widget as HTML using property values in field. """Renders this widget as HTML using property values in field.
""" """
...@@ -131,6 +138,10 @@ class Widget: ...@@ -131,6 +138,10 @@ class Widget:
except KeyError: except KeyError:
# In case extra is not defined as in DateTimeWidget # In case extra is not defined as in DateTimeWidget
extra = '' extra = ''
try:
gadget_url_js = field.get_value('gadget_url_js')
except KeyError:
gadget_url_js = ''
result = '' result = ''
# We must adapt the rendering to the type of the value # We must adapt the rendering to the type of the value
# in order to get the correct type back # in order to get the correct type back
...@@ -140,13 +151,15 @@ class Widget: ...@@ -140,13 +151,15 @@ class Widget:
type="hidden", type="hidden",
name="%s:list" % key, name="%s:list" % key,
value=v, value=v,
extra=extra) extra=extra,
gadget_url_js=gadget_url_js)
else: else:
result = render_element("input", result = render_element("input",
type="hidden", type="hidden",
name=key, name=key,
value=value, value=value,
extra=extra) extra=extra,
gadget_url_js=gadget_url_js)
return result return result
def render_view(self, field, value, REQUEST=None, render_prefix=None): def render_view(self, field, value, REQUEST=None, render_prefix=None):
...@@ -333,7 +346,8 @@ class TextWidget(Widget): ...@@ -333,7 +346,8 @@ class TextWidget(Widget):
"""Text widget """Text widget
""" """
property_names = Widget.property_names +\ property_names = Widget.property_names +\
['display_width', 'display_maxwidth', 'input_type', 'extra'] ['display_width', 'display_maxwidth', 'input_type', 'extra',
'gadget_url_js']
default = fields.StringField('default', default = fields.StringField('default',
title='Default', title='Default',
...@@ -382,7 +396,8 @@ class TextWidget(Widget): ...@@ -382,7 +396,8 @@ class TextWidget(Widget):
value=value, value=value,
size=field.get_value('display_width'), size=field.get_value('display_width'),
maxlength=display_maxwidth, maxlength=display_maxwidth,
extra=field.get_value('extra')) extra=field.get_value('extra'),
gadget_url_js=field.get_value('gadget_url_js'))
else: else:
return render_element("input", return render_element("input",
type=input_type, type=input_type,
...@@ -390,7 +405,8 @@ class TextWidget(Widget): ...@@ -390,7 +405,8 @@ class TextWidget(Widget):
css_class=field.get_value('css_class'), css_class=field.get_value('css_class'),
value=value, value=value,
size=field.get_value('display_width'), size=field.get_value('display_width'),
extra=field.get_value('extra')) extra=field.get_value('extra'),
gadget_url_js=field.get_value('gadget_url_js'))
def render_view(self, field, value, REQUEST=None, render_prefix=None): def render_view(self, field, value, REQUEST=None, render_prefix=None):
"""Render text as non-editable. """Render text as non-editable.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment