Commit a7ca7967 authored by Vincent Pelletier's avatar Vincent Pelletier

Fix validators for multi- fields : add a marker field to be able to save the...

Fix validators for multi- fields : add a marker field to be able to save the field value "nothing selected". Thanks to Rafael Monnerat for the patch.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9825 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3c5221e7
......@@ -615,8 +615,8 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST):
extra_item)
rendered_items.append(rendered_item)
rendered_items.append(render_element('input', type='hidden', name="default_%s:int" % (key, ), value="0")) # Added marker field
# Moved marked field to Render
# rendered_items.append(render_element('input', type='hidden', name="default_%s:int" % (key, ), value="0"))
return rendered_items
MultiItemsWidget.render_items = MultiItemsWidget_render_items
......@@ -625,7 +625,8 @@ from Products.Formulator.Widget import MultiListWidget
def MultiListWidget_render(self, field, key, value, REQUEST):
rendered_items = self.render_items(field, key, value, REQUEST)
return render_element(
input_hidden = render_element('input', type='hidden', name="default_%s:int" % (key, ), value="0")
multi_list = render_element(
'select',
name=key,
multiple=None,
......@@ -634,13 +635,29 @@ def MultiListWidget_render(self, field, key, value, REQUEST):
contents=string.join(rendered_items, "\n"),
extra=field.get_value('extra', REQUEST=REQUEST))
return "\n".join([multi_list,input_hidden])
MultiListWidget.render = MultiListWidget_render
from Products.Formulator.Widget import MultiCheckBoxWidget
def MultiCheckBoxWidget_render(self, field, key, value, REQUEST):
rendered_items = self.render_items(field, key, value, REQUEST)
rendered_items.append(render_element('input', type='hidden', name="default_%s:int" % (key, ), value="0"))
orientation = field.get_value('orientation')
if orientation == 'horizontal':
return string.join(rendered_items, "  ")
else:
return string.join(rendered_items, "<br />")
MultiCheckBoxWidget.render = MultiCheckBoxWidget_render
from Products.Formulator.Widget import ListWidget
def ListWidget_render(self, field, key, value, REQUEST):
rendered_items = self.render_items(field, key, value, REQUEST)
return render_element(
input_hidden = render_element('input', type='hidden', name="default_%s:int" % (key, ), value="0")
list_widget = render_element(
'select',
name=key,
css_class=field.get_value('css_class', REQUEST=REQUEST),
......@@ -648,6 +665,8 @@ def ListWidget_render(self, field, key, value, REQUEST):
contents=string.join(rendered_items, "\n"),
extra=field.get_value('extra', REQUEST=REQUEST))
return "\n".join([list_widget,input_hidden])
ListWidget.render = ListWidget_render
# JPS - Subfield handling with listbox requires extension
......
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