diff --git a/product/ERP5Form/EditorField.py b/product/ERP5Form/EditorField.py index b6a5099985d7241faeba0e74f9ec54f7fb46a7e4..1a19f2b6aba51af01676101597b7f49b66d44b2a 100644 --- a/product/ERP5Form/EditorField.py +++ b/product/ERP5Form/EditorField.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2002-2006 Nexedi SARL and Contributors. All Rights Reserved. @@ -89,8 +90,14 @@ class EditorWidget(Widget.TextAreaWidget): Render form in view only mode. """ if value is None: - value = '' - return value + return '' + text_editor = field.get_value('text_editor') + if text_editor == 'text_area': + return Widget.TextAreaWidget.render_view(self, field, value, + REQUEST=REQUEST, + render_prefix=REQUEST) + else: + return value EditorWidgetInstance = EditorWidget() diff --git a/product/ERP5Form/tests/testFields.py b/product/ERP5Form/tests/testFields.py index 6a63b7db843d83677897b543d5c2f2c3febd9ccf..1ce3a91c2335a8803aefd3bfffbe752170237b54 100644 --- a/product/ERP5Form/tests/testFields.py +++ b/product/ERP5Form/tests/testFields.py @@ -49,7 +49,7 @@ from Products.ERP5Form.Form import ERP5Form from Products.ERP5Form.Form import purgeFieldValueCache from Products.ERP5Form.Form import getFieldValue from Products.ERP5Form import Form -from Products.ERP5Form import ProxyField +from Products.ERP5Form import ProxyField, EditorField from DateTime import DateTime from Products.Formulator.Widget import NSMAP @@ -297,6 +297,18 @@ class TestTextAreaField(ERP5TypeTestCase): .xpath('%s/text:tab' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP) self.assertTrue(test_value) +class TestEditorField(TestTextAreaField): + """Tests Editor field + """ + + def getTitle(self): + return "Editor Field" + + def afterSetUp(self): + self.field = EditorField.EditorField('test_field') + self.widget = self.field.widget + + class TestLinesField(ERP5TypeTestCase): def getTitle(self): @@ -803,6 +815,7 @@ def test_suite(): suite.addTest(unittest.makeSuite(TestStringField)) suite.addTest(unittest.makeSuite(TestDateTimeField)) suite.addTest(unittest.makeSuite(TestTextAreaField)) + suite.addTest(unittest.makeSuite(TestEditorField)) suite.addTest(unittest.makeSuite(TestLinesField)) suite.addTest(unittest.makeSuite(TestCheckBoxField)) suite.addTest(unittest.makeSuite(TestListField))