Commit a804212e authored by Vincent Pelletier's avatar Vincent Pelletier

Allow formbox_target_id to be None or empty string.

This way, it's possible to display nothing in a FormBox.
Useful only when formbox_target_id is computed.
parent 0aeebead
......@@ -74,7 +74,7 @@ class FormBoxWidget(Widget.Widget):
description=(
"ID of the form which must be rendered in this box."),
default="",
required=1)
required=0)
default = fields.StringField(
'default',
......@@ -94,14 +94,17 @@ class FormBoxWidget(Widget.Widget):
# using 'cell' parameter.
if not REQUEST.has_key('cell'):
REQUEST.set('cell', here)
try:
form = getattr(here, field.get_value('formbox_target_id'))
except AttributeError:
LOG('FormBox', WARNING,
'Could not get a form from formbox %s in %s' % \
(field.id, field.aq_parent.id))
return ''
return form(REQUEST=REQUEST, key_prefix=key)
target_id = field.get_value('formbox_target_id')
if target_id not in (None, ''):
try:
form = getattr(here, target_id)
except AttributeError:
LOG('FormBox', WARNING,
'Could not get a form from formbox %s in %s' % \
(field.id, field.aq_parent.id))
else:
result = form(REQUEST=REQUEST, key_prefix=key)
return result
class FormBoxEditor:
"""
......
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