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