Commit 8493bb16 authored by Jérome Perrin's avatar Jérome Perrin

Listbox: Use an hidden field so that validator knows that listbox was empty

This way validator scripts will be called even for empty listboxs, and this
should also remove ERP5Form/Form.py:validate_all KeyError : 'Field listbox is
not present in request object.' messages from the logs
parent 7567efe0
......@@ -503,6 +503,8 @@
<span i18n:translate="" i18n:domain="ui">\n
No result.\n
</span>\n
<input type="hidden" value="1" name="listbox_empty:boolean"\n
tal:attributes="name string:${field_prefix}${field_id}_empty:boolean" />\n
</td>\n
</tr>\n
</tbody>\n
......
1089
\ No newline at end of file
1090
\ No newline at end of file
......@@ -2762,11 +2762,15 @@ class ListBoxValidator(Validator.Validator):
result = {}
error_result = {}
try:
listbox_uids = REQUEST['%s_uid' % field.id]
except KeyError:
raise KeyError('Field %s is not present in request object.'
% field.id)
listbox_empty = REQUEST.get('%s_empty' % field.id, False)
if listbox_empty:
listbox_uids = []
else:
try:
listbox_uids = REQUEST['%s_uid' % field.id]
except KeyError:
raise KeyError('Field %s is not present in request object.'
% field.id)
select = field.get_value('select')
if select:
selected_uid_set = set(REQUEST.get('uids', ()))
......
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