Commit 0454bdf6 authored by Vincent Pelletier's avatar Vincent Pelletier

Don't try to validate fields from hidden group.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10141 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 260866eb
...@@ -405,29 +405,32 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -405,29 +405,32 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
# import pdb; pdb.set_trace() # import pdb; pdb.set_trace()
result = {} result = {}
errors = [] errors = []
for field in self.get_fields(): for group in self.get_groups():
# skip any field we don't need to validate if group.lower() == 'hidden':
if not field.need_validate(REQUEST):
continue continue
if not (field.get_value('editable',REQUEST=REQUEST)): for field in self.get_fields_in_group(group):
continue # skip any field we don't need to validate
try: if not field.need_validate(REQUEST):
value = field.validate(REQUEST) continue
# store under id if not (field.get_value('editable',REQUEST=REQUEST)):
result[field.id] = value continue
# store as alternate name as well if necessary try:
alternate_name = field.get_value('alternate_name') value = field.validate(REQUEST)
if alternate_name: # store under id
result[alternate_name] = value result[field.id] = value
except FormValidationError, e: # XXX JPS Patch for listbox # store as alternate name as well if necessary
#LOG('validate_all', 0, 'FormValidationError: field = %s, errors=%s' % (repr(field), repr(errors))) alternate_name = field.get_value('alternate_name')
errors.extend(e.errors) if alternate_name:
result.update(e.result) result[alternate_name] = value
except ValidationError, err: except FormValidationError, e: # XXX JPS Patch for listbox
#LOG('validate_all', 0, 'ValidationError: field.id = %s, err=%s' % (repr(field.id), repr(err))) #LOG('validate_all', 0, 'FormValidationError: field = %s, errors=%s' % (repr(field), repr(errors)))
errors.append(err) errors.extend(e.errors)
except KeyError, err: result.update(e.result)
LOG('ERP5Form/Form.py:validate_all', 0, 'KeyError : %s' % (err, )) except ValidationError, err:
#LOG('validate_all', 0, 'ValidationError: field.id = %s, err=%s' % (repr(field.id), repr(err)))
errors.append(err)
except KeyError, err:
LOG('ERP5Form/Form.py:validate_all', 0, 'KeyError : %s' % (err, ))
if len(errors) > 0: if len(errors) > 0:
raise FormValidationError(errors, result) raise FormValidationError(errors, result)
return result return result
......
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