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
...@@ -614,9 +614,9 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST): ...@@ -614,9 +614,9 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST):
css_class, css_class,
extra_item) extra_item)
rendered_items.append(rendered_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 return rendered_items
MultiItemsWidget.render_items = MultiItemsWidget_render_items MultiItemsWidget.render_items = MultiItemsWidget_render_items
...@@ -625,29 +625,48 @@ from Products.Formulator.Widget import MultiListWidget ...@@ -625,29 +625,48 @@ from Products.Formulator.Widget import MultiListWidget
def MultiListWidget_render(self, field, key, value, REQUEST): def MultiListWidget_render(self, field, key, value, REQUEST):
rendered_items = self.render_items(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")
'select', multi_list = render_element(
name=key, 'select',
multiple=None, name=key,
css_class=field.get_value('css_class', REQUEST=REQUEST), multiple=None,
size=field.get_value('size', REQUEST=REQUEST), css_class=field.get_value('css_class', REQUEST=REQUEST),
contents=string.join(rendered_items, "\n"), size=field.get_value('size', REQUEST=REQUEST),
extra=field.get_value('extra', REQUEST=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 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 from Products.Formulator.Widget import ListWidget
def ListWidget_render(self, field, key, value, REQUEST): def ListWidget_render(self, field, key, value, REQUEST):
rendered_items = self.render_items(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")
'select', list_widget = render_element(
name=key, 'select',
css_class=field.get_value('css_class', REQUEST=REQUEST), name=key,
size=field.get_value('size', REQUEST=REQUEST), css_class=field.get_value('css_class', REQUEST=REQUEST),
contents=string.join(rendered_items, "\n"), size=field.get_value('size', REQUEST=REQUEST),
extra=field.get_value('extra', REQUEST=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 ListWidget.render = ListWidget_render
# JPS - Subfield handling with listbox requires extension # 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