From e7b3d88fe4812473ca07d8b1ff43d1614b83c52c Mon Sep 17 00:00:00 2001 From: Ivan Tyagov <ivan@nexedi.com> Date: Wed, 15 Sep 2010 10:46:51 +0000 Subject: [PATCH] Set in REQUEST the current ERP5 form & field id in a similar way as 'cell' request argument.This allows scipts used for listbox rendering be aware of current ERP5 form being rendered and access form itself. Add test for this. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38382 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/ListBox.py | 6 ++++++ product/ERP5Form/tests/testListBox.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py index 5d59bc2046..491cec0c7d 100644 --- a/product/ERP5Form/ListBox.py +++ b/product/ERP5Form/ListBox.py @@ -2616,6 +2616,12 @@ class ListBoxHTMLRenderer(ListBoxRenderer): selection.edit(method_path = method_path, list_url = list_url) self.getSelectionTool().setSelectionFor(self.getSelectionName(), selection, REQUEST = self.request) + # do pass current form and respective field through request + request = self.request + field_id = self.getId() + form = self.getForm() + request.set('form_id', form.getId()) + request.set('field_id', field_id) pt = self.getPageTemplate() return pt() diff --git a/product/ERP5Form/tests/testListBox.py b/product/ERP5Form/tests/testListBox.py index 4c18a81782..106c638e9c 100644 --- a/product/ERP5Form/tests/testListBox.py +++ b/product/ERP5Form/tests/testListBox.py @@ -622,6 +622,20 @@ return [] self.assertSameSet([('id', u'ID'), ('title', u'Title'), ('getQuantity', u'Quantity')], getListBoxRenderer(listbox).getSelectedColumnList()) + def test_ListboxRequestParameterPropagandation(self): + """ + Test that rendering a listbox field will set respective form & field_id of current form + in REQUEST for further usage by used by litsbox's columns methods. + """ + portal = self.getPortal() + request = get_request() + portal.ListBoxZuite_reset() + form = portal.FooModule_viewFooList + self.assertEqual(None, request.get('form_id')) + form.render() + self.assertEqual(form.getId(), request.get('form_id')) + self.assertEqual(form.listbox.getId(), request.get('field_id')) + def test_suite(): suite = unittest.TestSuite() -- 2.30.9