Commit 63cd23c7 authored by Nicolas Delaby's avatar Nicolas Delaby

Override _get_user_input_value in order to let ParallelListField retrieve its values

when it is used inside a Listbox.
The patch consist into iteration over each subfield keys in order to retrieve values from
REQUEST for each occurrence of subfields.

Fix the display of dialog when validation of form fails, because user filled values are not lost.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40170 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ffd0b559
......@@ -234,6 +234,46 @@ class ParallelListField(ZMIField):
"""
return paralellListFieldGetValue(self, id, REQUEST=REQUEST, **kw)
def _get_user_input_value(self, key, REQUEST):
"""
Try to get a value of the field from the REQUEST.
This method is extended in order to retrive values
from REQUEST for each subfield.
then a list of values will be returned
This is required for parallel listfields inside listbox
"""
value_list = []
try:
value = REQUEST.form[key]
except (KeyError, AttributeError):
# Fallback with id of field on rendered form
# So try to get the proxy_field if exists
# because template field may have a different id.
# And configuration of properties
# can be different (not delegated)
# So the following code works only with original field
# ie: proxy_field
field = REQUEST.get(
'field__proxyfield_%s_%s_%s' % (self.id, self._p_oid, 'default'),
self)
# call hash_list to iterate over each subfield
hash_list = generateSubForm(field, [], REQUEST)
for sub_field_property_dict in hash_list:
# compute if of each subfield
sub_key = field.generate_subfield_key(sub_field_property_dict['key'],
key=key)
# retrieve the user filled value in REQUEST
sub_value = REQUEST.get(sub_key, MARKER)
if sub_value is not MARKER:
value_list.append(sub_value)
if not value_list:
# Raise KeyError if any value has not been found
# This reproduce expected behaviour of
# REQUEST.form[key]
raise KeyError
value = value_list
return value
def generateSubForm(self, value, REQUEST):
item_list = [x for x in self.get_value('items', REQUEST=REQUEST)
if x[0] != '' and x[1]]
......
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