Modified form interfaces for subforms and groups
authorThierry Florac <thierry.florac@onf.fr>
Wed, 01 Jul 2015 10:10:03 +0200
changeset 18 a36d954c4adb
parent 17 c42f7fcd6cfe
child 19 ee1e85bd3580
Modified form interfaces for subforms and groups
src/pyams_form/interfaces/__init__.py
src/pyams_form/interfaces/form.py
--- a/src/pyams_form/interfaces/__init__.py	Wed Jun 17 09:56:44 2015 +0200
+++ b/src/pyams_form/interfaces/__init__.py	Wed Jul 01 10:10:03 2015 +0200
@@ -18,3 +18,11 @@
 from .form import IForm, IFormLayer
 
 # import packages
+
+
+def get_form_weight(form):
+    """Try to get form weight attribute"""
+    try:
+        return form.weight
+    except AttributeError:
+        return 0
--- a/src/pyams_form/interfaces/form.py	Wed Jun 17 09:56:44 2015 +0200
+++ b/src/pyams_form/interfaces/form.py	Wed Jul 01 10:10:03 2015 +0200
@@ -180,6 +180,9 @@
 class IFormWidgetsGroup(Interface):
     """Form widgets group interface"""
 
+    form = Object(title="Parent form",
+                  schema=IForm)
+
     id = TextLine(title="Group ID",
                   required=False)
 
@@ -232,10 +235,24 @@
 
     checker_state = Attribute("Checker state")
 
+    subforms = List(title="Sub-forms",
+                    value_type=Object(schema=ISubForm),
+                    required=False,
+                    readonly=True)
+
+    subforms_legend = TextLine(title="Sub-forms legend",
+                               required=False)
+
 
 class IGroupsBasedForm(IBaseForm):
     """Groups based form"""
 
+    main_group_legend = TextLine(title="Default group legend",
+                                 required=False)
+
+    main_group_class = TextLine(title='Default group CSS class',
+                                default='inner')
+
     groups = List(title="Form widgets groups",
                   value_type=Object(IFormWidgetsGroup))