diff --git a/product/ERP5Form/Form.py b/product/ERP5Form/Form.py index 4beb3c69a44fc3f96b3e2b9a07dbdf057da9c5bc..21fc4896870bd160eb403ad8d3f883e84b1f2053 100755 --- a/product/ERP5Form/Form.py +++ b/product/ERP5Form/Form.py @@ -77,6 +77,9 @@ def get_value(self, id, **kw): except AttributeError : LOG('ERP5Form', 0, 'portal_preferences not put in TALES context (not installed?)') + extra_context = getattr(self, '_v_extra_context', None) + if extra_context: + kw.update(extra_context) # This allows to pass some pointer to the local object # through the REQUEST parameter. Not very clean. # Used by ListBox to render different items in a list diff --git a/product/ERP5Form/ProxyField.py b/product/ERP5Form/ProxyField.py index f1b9cdd321dc569a7ce5001fb0ae4374376180c8..b03a121b38514121fd16131762eec48f13320c21 100755 --- a/product/ERP5Form/ProxyField.py +++ b/product/ERP5Form/ProxyField.py @@ -55,6 +55,7 @@ class ProxyWidget(Widget.Widget): property_names = Widget.Widget.property_names + [ 'form_id', \ 'field_id', \ + 'extra_context', \ ] form_id = fields.StringField( @@ -81,6 +82,13 @@ class ProxyWidget(Widget.Widget): default="", required=0) + extra_context = fields.ListTextAreaField( + 'extra_context', + title='Extra Context', + description='Additional context variables.', + default=(), + required=0) + def render(self, field, key, value, REQUEST): """ @@ -89,6 +97,11 @@ class ProxyWidget(Widget.Widget): form = field.aq_parent proxy_form = getattr(form, field.get_value('form_id')) proxy_field = getattr(proxy_form, field.get_value('field_id')) + extra_context = field.get_value('extra_context') + if not hasattr(proxy_field, '_v_extra_context'): + proxy_field._v_extra_context = {} + for k, v in extra_context: + proxy_field._v_extra_context[k] = v return proxy_field.widget.render(proxy_field, key, value, REQUEST) def render_view(self, field, value): @@ -98,6 +111,11 @@ class ProxyWidget(Widget.Widget): form = field.aq_parent proxy_form = getattr(form, field.get_value('form_id')) proxy_field = getattr(proxy_form, field.get_value('field_id')) + extra_context = field.get_value('extra_context') + if not hasattr(proxy_field, '_v_extra_context'): + proxy_field._v_extra_context = {} + for k, v in extra_context: + proxy_field._v_extra_context[k] = v return proxy_field.widget.render_view(proxy_field, key, value) class ProxyValidator(Validator.Validator):