Add widgets check
authorThierry Florac <thierry.florac@onf.fr>
Thu, 14 Jun 2018 08:57:33 +0200
changeset 116 bf60719e676c
parent 115 0d6b79be4eb1
child 117 3f6f7f27216f
Add widgets check
src/pyams_form/group.py
--- a/src/pyams_form/group.py	Tue Jun 12 10:49:14 2018 +0200
+++ b/src/pyams_form/group.py	Thu Jun 14 08:57:33 2018 +0200
@@ -179,18 +179,19 @@
     def groups(self):
         result = self._groups[:]
         others = []
-        for widget in self.widgets.values():
-            found = False
-            for group in result:
-                if widget in group.widgets:
-                    found = True
-                    break
-            if not found:
-                others.append(widget)
-        if others:
-            result.insert(0, FormWidgetsGroup(self, None, others,
-                                              legend=self.main_group_legend,
-                                              css_class=self.main_group_class))
+        if self.widgets:
+            for widget in self.widgets.values():
+                found = False
+                for group in result:
+                    if widget in group.widgets:
+                        found = True
+                        break
+                if not found:
+                    others.append(widget)
+            if others:
+                result.insert(0, FormWidgetsGroup(self, None, others,
+                                                  legend=self.main_group_legend,
+                                                  css_class=self.main_group_class))
         return result
 
     def updateGroups(self):