Merge lists and tuples when updating JSON response from several subforms
authorThierry Florac <thierry.florac@onf.fr>
Fri, 15 Jun 2018 18:17:32 +0200
changeset 118 0d462137f10d
parent 117 3f6f7f27216f
child 119 77ad84e8b837
Merge lists and tuples when updating JSON response from several subforms
src/pyams_form/form.py
--- a/src/pyams_form/form.py	Thu Jun 14 10:35:51 2018 +0200
+++ b/src/pyams_form/form.py	Fri Jun 15 18:17:32 2018 +0200
@@ -430,6 +430,9 @@
             try:
                 form_output = form.get_ajax_output(changes)
                 if form_output:
+                    for key, value in form_output.items():
+                        if isinstance(value, (list, tuple)) and (key in output):  # concatenate lists
+                            form_output[key] += output[key]
                     output.update(form_output)
             except NotImplementedError:
                 pass
@@ -563,6 +566,9 @@
             try:
                 form_output = form.get_ajax_output(changes)
                 if form_output:
+                    for key, value in form_output.items():
+                        if isinstance(value, (list, tuple)) and (key in output):  # concatenate lists
+                            form_output[key] += output[key]
                     output.update(form_output)
             except NotImplementedError:
                 pass