Commit 528c2b1e authored by Jérome Perrin's avatar Jérome Perrin

Get the 'sub_form' attribute dynamically from the template field.

Before that the text version of the sub_form was stored on the proxy field instance.
If you want to use list datetime fields, I'll add a note on UpgradeNote wiki page.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17537 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5a00ccb9
......@@ -368,6 +368,11 @@ class ProxyField(ZMIField):
field = template_field
return template_field
def _aq_dynamic(self, name):
if name == 'sub_form':
return self.getTemplateField().sub_form
return None
security.declareProtected('Access contents information',
'is_delegated')
def is_delegated(self, id):
......
......@@ -50,6 +50,7 @@ Globals.get_request = get_request
from Testing import ZopeTestCase
ZopeTestCase.installProduct('ERP5Form')
from Acquisition import aq_base
from Products.Formulator.StandardFields import FloatField
from Products.Formulator.StandardFields import StringField
from Products.Formulator.StandardFields import DateTimeField
......@@ -251,6 +252,24 @@ class TestProxyField(unittest.TestCase):
self.assertEquals(other_field, proxy_field.getTemplateField())
self.assertEquals('Other', proxy_field.get_value('title'))
def test_proxy_to_date_time_field(self):
# date time fields are specific, because they use a 'sub_form', we must
# make sure this works as expected
original_field = self.addField(self.container.Base_viewProxyFieldLibrary,
'my_date', 'Date', 'DateTimeField')
original_field.manage_edit_xmlrpc(dict(required=0))
proxy_field = self.addField(self.container.Base_view,
'my_date', 'Date', 'ProxyField')
proxy_field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary',
field_id='my_date',))
self.assertTrue(hasattr(proxy_field, 'sub_form'))
self.assertTrue(aq_base(proxy_field.sub_form) is
aq_base(original_field.sub_form))
# we can render
proxy_field.render()
# and validate
self.container.Base_view.validate_all_to_request(dict())
class TestFieldValueCache(unittest.TestCase):
"""Tests field value caching system
......
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