Commit d7837b26 authored by Nicolas Delaby's avatar Nicolas Delaby

If Editor field edit raw_text, it should behave like TextAreaField,

So use TextAreaWidget.render_view for that specific case.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33918 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 07e8c0dd
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002-2006 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002-2006 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -89,7 +90,13 @@ class EditorWidget(Widget.TextAreaWidget): ...@@ -89,7 +90,13 @@ class EditorWidget(Widget.TextAreaWidget):
Render form in view only mode. Render form in view only mode.
""" """
if value is None: if value is None:
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 return value
EditorWidgetInstance = EditorWidget() EditorWidgetInstance = EditorWidget()
......
...@@ -49,7 +49,7 @@ from Products.ERP5Form.Form import ERP5Form ...@@ -49,7 +49,7 @@ from Products.ERP5Form.Form import ERP5Form
from Products.ERP5Form.Form import purgeFieldValueCache from Products.ERP5Form.Form import purgeFieldValueCache
from Products.ERP5Form.Form import getFieldValue from Products.ERP5Form.Form import getFieldValue
from Products.ERP5Form import Form from Products.ERP5Form import Form
from Products.ERP5Form import ProxyField from Products.ERP5Form import ProxyField, EditorField
from DateTime import DateTime from DateTime import DateTime
from Products.Formulator.Widget import NSMAP from Products.Formulator.Widget import NSMAP
...@@ -297,6 +297,18 @@ class TestTextAreaField(ERP5TypeTestCase): ...@@ -297,6 +297,18 @@ class TestTextAreaField(ERP5TypeTestCase):
.xpath('%s/text:tab' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP) .xpath('%s/text:tab' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)
self.assertTrue(test_value) 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): class TestLinesField(ERP5TypeTestCase):
def getTitle(self): def getTitle(self):
...@@ -803,6 +815,7 @@ def test_suite(): ...@@ -803,6 +815,7 @@ def test_suite():
suite.addTest(unittest.makeSuite(TestStringField)) suite.addTest(unittest.makeSuite(TestStringField))
suite.addTest(unittest.makeSuite(TestDateTimeField)) suite.addTest(unittest.makeSuite(TestDateTimeField))
suite.addTest(unittest.makeSuite(TestTextAreaField)) suite.addTest(unittest.makeSuite(TestTextAreaField))
suite.addTest(unittest.makeSuite(TestEditorField))
suite.addTest(unittest.makeSuite(TestLinesField)) suite.addTest(unittest.makeSuite(TestLinesField))
suite.addTest(unittest.makeSuite(TestCheckBoxField)) suite.addTest(unittest.makeSuite(TestCheckBoxField))
suite.addTest(unittest.makeSuite(TestListField)) suite.addTest(unittest.makeSuite(TestListField))
......
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