From 0ce4a10a870bf6bd9339ba2e961f93e8d861697e Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Tue, 22 Aug 2006 16:34:20 +0000 Subject: [PATCH] Fix MultiListField and MultiCheckBoxField : "nothing is selected" state will be saved (distinguished from "not rendered" state). git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9332 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/FormulatorPatch.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/product/ERP5Form/FormulatorPatch.py b/product/ERP5Form/FormulatorPatch.py index b2f2cababe..6465d7c254 100644 --- a/product/ERP5Form/FormulatorPatch.py +++ b/product/ERP5Form/FormulatorPatch.py @@ -180,12 +180,10 @@ SelectionValidator.validate = SelectionValidator_validate from Products.Formulator.Validator import MultiSelectionValidator def MultiSelectionValidator_validate(self, field, key, REQUEST): - values = REQUEST.get(key) - if values is None: - if field.get_value('required'): - raise Exception, 'Required field %s has not been transmitted. Check that all required fields are in visible groups.' % (repr(field.id), ) - else: - raise KeyError, 'Field %s is not present in request object.' % (repr(field.id), ) + if REQUEST.get('default_%s' % (key, )) is None: + LOG('MultiSelectionValidator_validate', 0, 'Field %s is not present in request object (marker field default_%s not found).' % (repr(field.id), key)) + raise KeyError, 'Field %s is not present in request object (marker field default_%s not found).' % (repr(field.id), key) + values = REQUEST.get(key, []) # NOTE: a hack to deal with single item selections if type(values) is not type([]): # put whatever we got in a list @@ -576,7 +574,7 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST): # XXX -yo selected_found = {} - items = field.get_value('items',REQUEST=REQUEST, cell=getattr(REQUEST,'cell',None)) # The only thing changes, added request + items = field.get_value('items',REQUEST=REQUEST, cell=getattr(REQUEST,'cell',None)) # Added request css_class = field.get_value('css_class') extra_item = field.get_value('extra_item') rendered_items = [] @@ -616,6 +614,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 + return rendered_items MultiItemsWidget.render_items = MultiItemsWidget_render_items -- 2.30.9