Commit 5ab515c7 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Patch the render_view of LinkField so that it is displayed as a clickable link in read-only mode.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1899 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 79d2be5e
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
############################################################################## ##############################################################################
from Products.Formulator.Field import Field from Products.Formulator.Field import Field
from Products.Formulator.Widget import Widget
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from zLOG import LOG from zLOG import LOG
...@@ -223,6 +224,29 @@ def TextAreaWidget_render_view(self, field, value): ...@@ -223,6 +224,29 @@ def TextAreaWidget_render_view(self, field, value):
TextAreaWidget.render_view = TextAreaWidget_render_view TextAreaWidget.render_view = TextAreaWidget_render_view
# Patch the render_view of LinkField so that it is clickable in read-only mode.
from Products.Formulator.Widget import TextWidget
from Products.Formulator.StandardFields import LinkField
from Globals import get_request
from urlparse import urljoin
class PatchedLinkWidget(TextWidget) :
def render_view(self, field, value) :
"""Render link.
"""
REQUEST = get_request()
link_type = field.get_value('link_type')
if link_type == 'internal':
value = urljoin(REQUEST['BASE0'], value)
elif link_type == 'relative':
value = urljoin(REQUEST['URL1'], value)
return '<a href="%s">%s</a>' % (value, field.get_value('title', cell=REQUEST.get('cell')))
PatchedLinkWidgetInstance = PatchedLinkWidget()
LinkField.widget = PatchedLinkWidgetInstance
import string import string
def StringBaseValidator_validate(self, field, key, REQUEST): def StringBaseValidator_validate(self, field, key, REQUEST):
...@@ -236,8 +260,6 @@ def StringBaseValidator_validate(self, field, key, REQUEST): ...@@ -236,8 +260,6 @@ def StringBaseValidator_validate(self, field, key, REQUEST):
StringBaseValidator.validate = StringBaseValidator_validate StringBaseValidator.validate = StringBaseValidator_validate
from Products.Formulator.Widget import Widget
def render_hidden(self, field, key, value, REQUEST): def render_hidden(self, field, key, value, REQUEST):
"""Renders this widget as a hidden field. """Renders this widget as a hidden field.
""" """
......
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