Commit cde1413b authored by Sebastien Robin's avatar Sebastien Robin

make sure a field need validation before returning it to Base_edit


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3134 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 96948b7e
...@@ -2025,16 +2025,17 @@ class ListBoxValidator(Validator.Validator): ...@@ -2025,16 +2025,17 @@ class ListBoxValidator(Validator.Validator):
my_field_id = '%s_%s' % (field.id, alias) my_field_id = '%s_%s' % (field.id, alias)
if form.has_field( my_field_id ): if form.has_field( my_field_id ):
my_field = form.get_field(my_field_id) my_field = form.get_field(my_field_id)
key = 'field_' + my_field.id + '_%s' % o.uid if my_field.get_value('editable') and field.need_validate(REQUEST):
error_result_key = my_field.id + '_%s' % o.uid key = 'field_' + my_field.id + '_%s' % o.uid
REQUEST.cell = o error_result_key = my_field.id + '_%s' % o.uid
try: REQUEST.cell = o
value = my_field.validator.validate(my_field, key, REQUEST) # We need cell try:
result[uid[4:]][sql] = value value = my_field.validator.validate(my_field, key, REQUEST) # We need cell
except ValidationError, err: result[uid[4:]][sql] = value
#LOG("ListBox ValidationError",0,str(err)) except ValidationError, err:
err.field_id = error_result_key #LOG("ListBox ValidationError",0,str(err))
errors.append(err) err.field_id = error_result_key
errors.append(err)
else: else:
# Second case: modification of existing objects # Second case: modification of existing objects
#try: #try:
...@@ -2051,20 +2052,21 @@ class ListBoxValidator(Validator.Validator): ...@@ -2051,20 +2052,21 @@ class ListBoxValidator(Validator.Validator):
my_field_id = '%s_%s' % (field.id, alias) my_field_id = '%s_%s' % (field.id, alias)
if form.has_field( my_field_id ): if form.has_field( my_field_id ):
my_field = form.get_field(my_field_id) my_field = form.get_field(my_field_id)
tales_expr = my_field.tales.get('default', "") if my_field.get_value('editable') and field.need_validate(REQUEST):
key = 'field_' + my_field.id + '_%s' % o.uid tales_expr = my_field.tales.get('default', "")
error_result_key = my_field.id + '_%s' % o.uid key = 'field_' + my_field.id + '_%s' % o.uid
REQUEST.cell = o # We need cell error_result_key = my_field.id + '_%s' % o.uid
try: REQUEST.cell = o # We need cell
value = my_field.validator.validate(my_field, key, REQUEST) # We need cell try:
error_result[error_result_key] = value value = my_field.validator.validate(my_field, key, REQUEST) # We need cell
if not result.has_key(o.getUrl()): error_result[error_result_key] = value
result[o.getUrl()] = {} if not result.has_key(o.getUrl()):
result[o.getUrl()][sql] = value result[o.getUrl()] = {}
except ValidationError, err: result[o.getUrl()][sql] = value
#LOG("ListBox ValidationError",0,str(err)) except ValidationError, err:
err.field_id = error_result_key #LOG("ListBox ValidationError",0,str(err))
errors.append(err) err.field_id = error_result_key
errors.append(err)
#except: #except:
else: else:
LOG("ListBox WARNING",0,"Object uid %s could not be validated" % uid) LOG("ListBox WARNING",0,"Object uid %s could not be validated" % uid)
......
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