Commit fa21ea71 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Better support of cell parameter and editable property in listbox embedded fields;

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15817 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d5f36099
......@@ -25,6 +25,7 @@ from Products.Formulator.Field import Field
from Products.Formulator.Widget import Widget
from Products.Formulator.Widget import render_element
from Products.Formulator.FieldRegistry import FieldRegistry
from ProxyField import ProxyField
from AccessControl import ClassSecurityInfo
from cgi import escape
import types
......@@ -92,9 +93,9 @@ def Field_validate_sub_field(self, id, REQUEST, key=None):
def Field_render_helper(self, key, value, REQUEST):
value = self._get_default(key, value, REQUEST)
__traceback_info__ = ('key=%s value=%r' % (key, value))
if self.get_value('hidden'):
if self.get_value('hidden', REQUEST=REQUEST):
return self.widget.render_hidden(self, key, value, REQUEST)
elif (not self.get_value('editable',REQUEST=REQUEST)):
elif (not self.get_value('editable', REQUEST=REQUEST)):
return self.widget.render_view(self, value)
else:
return self.widget.render(self, key, value, REQUEST)
......@@ -113,6 +114,8 @@ Field.validate_sub_field = Field_validate_sub_field
Field._render_helper = Field_render_helper
Field._get_user_input_value = Field_get_user_input_value
ProxyField._render_helper = Field_render_helper
from Products.Formulator.Validator import SelectionValidator
from Products.Formulator.Validator import StringBaseValidator
......
......@@ -2059,22 +2059,29 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
# the REQUEST into the brain. In addition, the define a
# cell property on the request itself so that forms may
# use the 'cell' value (refer to get_value method in Form.py)
cell_html = editable_field.render( \
value = display_value
, REQUEST = brain.asContext( \
REQUEST = self.renderer.request
cell_request = brain.asContext( REQUEST = self.renderer.request
, form = self.renderer.request.form
, cell = self.getObject()
)
if editable_field.get_value('enabled', REQUEST=cell_request):
cell_html = editable_field.render( \
value = display_value
, REQUEST = cell_request
, key = key
)
else:
cell_html = ''
else:
# If the brain does not support asContext (eg. it is None), no way
self.renderer.request.cell = self.getObject()
cell_request = brain
if editable_field.get_value('enabled', REQUEST=cell_request):
cell_html = editable_field.render( value = display_value
, REQUEST = brain
, REQUEST = cell_request
, key = key
)
else:
cell_html = ''
if isinstance(cell_html, str):
cell_html = unicode(cell_html, encoding)
......@@ -2082,7 +2089,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
if url is None:
html = cell_html + error_message
else:
if editable_field.get_value('editable'):
if editable_field.get_value('editable', REQUEST=cell_request):
html = u'%s' % cell_html
else:
html = u'<a href="%s">%s</a>' % (url, cell_html)
......
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