Added "update" method to form group
authorThierry Florac <thierry.florac@onf.fr>
Wed, 02 May 2018 15:44:53 +0200
changeset 101 ba1d62478119
parent 100 6584696a7e48
child 102 728821df9e89
Added "update" method to form group
src/pyams_form/group.py
src/pyams_form/interfaces/form.py
--- a/src/pyams_form/group.py	Fri Apr 27 18:17:26 2018 +0200
+++ b/src/pyams_form/group.py	Wed May 02 15:44:53 2018 +0200
@@ -134,11 +134,17 @@
                                                            IInnerSubForm)),
                       key=get_form_weight)
 
+    def update(self):
+        [subform.update() for subform in self.subforms]
+
 
 def NamedWidgetsGroup(form, id, widgets, names=(), bordered=True, fieldset_class=None, legend=None, help=None,
                       css_class='', switch=False, checkbox_switch=False, checkbox_field=None, checkbox_mode='hide',
                       hide_if_empty=False, factory=FormWidgetsGroup):
     """Create a widgets group based on widgets names"""
+    if widgets is None:
+        form.updateWidgets()
+        widgets = form.widgets
     return factory(form, id, [widgets.get(name) for name in names], bordered, fieldset_class, legend, help,
                    css_class, switch, checkbox_switch, checkbox_field, checkbox_mode, hide_if_empty)
 
--- a/src/pyams_form/interfaces/form.py	Fri Apr 27 18:17:26 2018 +0200
+++ b/src/pyams_form/interfaces/form.py	Wed May 02 15:44:53 2018 +0200
@@ -254,6 +254,9 @@
     subforms_legend = TextLine(title="Sub-forms legend",
                                required=False)
 
+    def update(self):
+        """Update inner group state"""
+
 
 class IGroupsBasedForm(IBaseForm):
     """Groups based form"""