Commit 0ce4a10a authored by Vincent Pelletier's avatar Vincent Pelletier

Fix MultiListField and MultiCheckBoxField : "nothing is selected" state will...

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
parent b9e76e30
...@@ -180,12 +180,10 @@ SelectionValidator.validate = SelectionValidator_validate ...@@ -180,12 +180,10 @@ SelectionValidator.validate = SelectionValidator_validate
from Products.Formulator.Validator import MultiSelectionValidator from Products.Formulator.Validator import MultiSelectionValidator
def MultiSelectionValidator_validate(self, field, key, REQUEST): def MultiSelectionValidator_validate(self, field, key, REQUEST):
values = REQUEST.get(key) if REQUEST.get('default_%s' % (key, )) is None:
if values is None: LOG('MultiSelectionValidator_validate', 0, 'Field %s is not present in request object (marker field default_%s not found).' % (repr(field.id), key))
if field.get_value('required'): raise KeyError, 'Field %s is not present in request object (marker field default_%s not found).' % (repr(field.id), key)
raise Exception, 'Required field %s has not been transmitted. Check that all required fields are in visible groups.' % (repr(field.id), ) values = REQUEST.get(key, [])
else:
raise KeyError, 'Field %s is not present in request object.' % (repr(field.id), )
# NOTE: a hack to deal with single item selections # NOTE: a hack to deal with single item selections
if type(values) is not type([]): if type(values) is not type([]):
# put whatever we got in a list # put whatever we got in a list
...@@ -576,7 +574,7 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST): ...@@ -576,7 +574,7 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST):
# XXX -yo # XXX -yo
selected_found = {} 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') css_class = field.get_value('css_class')
extra_item = field.get_value('extra_item') extra_item = field.get_value('extra_item')
rendered_items = [] rendered_items = []
...@@ -616,6 +614,8 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST): ...@@ -616,6 +614,8 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST):
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
return rendered_items return rendered_items
MultiItemsWidget.render_items = MultiItemsWidget_render_items MultiItemsWidget.render_items = MultiItemsWidget_render_items
......
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