--- a/src/pyams_form/form.py Mon Jan 18 17:50:02 2016 +0100
+++ b/src/pyams_form/form.py Mon Jan 18 17:51:15 2016 +0100
@@ -104,6 +104,7 @@
# check form permission to get form mode
if self.edit_permission and not self.request.has_permission(self.edit_permission, content):
self.mode = DISPLAY_MODE
+ return
# check form mode based on context checker
registry = self.request.registry
permission = None
--- a/src/pyams_form/group.py Mon Jan 18 17:50:02 2016 +0100
+++ b/src/pyams_form/group.py Mon Jan 18 17:51:15 2016 +0100
@@ -40,11 +40,12 @@
checkbox_switch = FieldProperty(IFormWidgetsGroup['checkbox_switch'])
checkbox_field = FieldProperty(IFormWidgetsGroup['checkbox_field'])
checkbox_widget = FieldProperty(IFormWidgetsGroup['checkbox_widget'])
+ checkbox_mode = FieldProperty(IFormWidgetsGroup['checkbox_mode'])
hide_if_empty = FieldProperty(IFormWidgetsGroup['hide_if_empty'])
subforms_legend = FieldProperty(IFormWidgetsGroup['subforms_legend'])
def __init__(self, form, id, widgets=None, bordered=True, legend=None, help=None, css_class='', switch=False,
- checkbox_switch=False, checkbox_field=None, hide_if_empty=False):
+ checkbox_switch=False, checkbox_field=None, checkbox_mode='hide', hide_if_empty=False):
assert (not checkbox_switch) or checkbox_field, "You must define checkbox field when using checkbox switch"
self.form = form
self.id = id
@@ -56,6 +57,7 @@
self.switch = switch
self.checkbox_switch = checkbox_switch
self.checkbox_field = checkbox_field
+ self.checkbox_mode = checkbox_mode
self.hide_if_empty = hide_if_empty
@property
@@ -125,10 +127,10 @@
def NamedWidgetsGroup(form, id, widgets, names=(), bordered=True, legend=None, help=None, css_class='', switch=False,
- checkbox_switch=False, checkbox_field=None, hide_if_empty=False):
+ checkbox_switch=False, checkbox_field=None, checkbox_mode='hide', hide_if_empty=False):
"""Create a widgets group based on widgets names"""
return FormWidgetsGroup(form, id, [widgets.get(name) for name in names], bordered, legend, help, css_class, switch,
- checkbox_switch, checkbox_field, hide_if_empty)
+ checkbox_switch, checkbox_field, checkbox_mode, hide_if_empty)
@implementer(IGroupsBasedForm)