Updated "get_forms" iterator
authorThierry Florac <thierry.florac@onf.fr>
Fri, 18 May 2018 15:55:52 +0200
changeset 105 2a73976299b3
parent 104 659ab1e14dca
child 106 2dbbb022d2e8
Updated "get_forms" iterator
src/pyams_form/form.py
src/pyams_form/group.py
--- a/src/pyams_form/form.py	Fri May 18 15:55:15 2018 +0200
+++ b/src/pyams_form/form.py	Fri May 18 15:55:52 2018 +0200
@@ -160,10 +160,11 @@
         if include_self:
             yield self
         for group in self.groups:
-            for subform in group.subforms:
+            for subform in group.get_forms():
                 yield subform
         for form in self.subforms:
-            yield form
+            for subform in form.get_forms():
+                yield subform
         for form in self.tabforms:
             yield form
 
@@ -320,6 +321,8 @@
         """Extract AJAX POST output"""
         output = {}
         for form in self.get_forms(include_self=False):
+            if form.mode == DISPLAY_MODE:
+                continue
             try:
                 form_output = form.get_ajax_output(changes)
                 if form_output:
--- a/src/pyams_form/group.py	Fri May 18 15:55:15 2018 +0200
+++ b/src/pyams_form/group.py	Fri May 18 15:55:52 2018 +0200
@@ -134,6 +134,11 @@
                                                            IInnerSubForm)),
                       key=get_form_weight)
 
+    def get_forms(self):
+        for form in self.subforms:
+            for subform in form.get_forms():
+                yield subform
+
     def update(self):
         [subform.update() for subform in self.subforms]