Let forms choose *not* to auto-disable their cancel button
This commit is contained in:
parent
00a3b8fc33
commit
c35bfa3e4e
|
@ -324,6 +324,8 @@ class Form(object):
|
||||||
update_label = "Save"
|
update_label = "Save"
|
||||||
show_cancel = True
|
show_cancel = True
|
||||||
auto_disable = True
|
auto_disable = True
|
||||||
|
auto_disable_save = True
|
||||||
|
auto_disable_cancel = True
|
||||||
|
|
||||||
def __init__(self, fields=None, schema=None, request=None, readonly=False, readonly_fields=[],
|
def __init__(self, fields=None, schema=None, request=None, readonly=False, readonly_fields=[],
|
||||||
model_instance=None, model_class=None, nodes={}, enums={}, labels={}, renderers=None,
|
model_instance=None, model_class=None, nodes={}, enums={}, labels={}, renderers=None,
|
||||||
|
@ -687,7 +689,8 @@ class Form(object):
|
||||||
context['form'] = self
|
context['form'] = self
|
||||||
context['dform'] = dform
|
context['dform'] = dform
|
||||||
context['form_kwargs'] = {}
|
context['form_kwargs'] = {}
|
||||||
if self.auto_disable:
|
# TODO: deprecate / remove the latter option here
|
||||||
|
if self.auto_disable_save or self.auto_disable:
|
||||||
context['form_kwargs']['class_'] = 'autodisable'
|
context['form_kwargs']['class_'] = 'autodisable'
|
||||||
context['request'] = self.request
|
context['request'] = self.request
|
||||||
context['readonly_fields'] = self.readonly_fields
|
context['readonly_fields'] = self.readonly_fields
|
||||||
|
|
|
@ -77,7 +77,7 @@ ${h.csrf_token(request)}
|
||||||
## ${h.submit('create_and_continue', form.successive_create_label)}
|
## ${h.submit('create_and_continue', form.successive_create_label)}
|
||||||
## % endif
|
## % endif
|
||||||
% if getattr(form, 'show_cancel', True):
|
% if getattr(form, 'show_cancel', True):
|
||||||
${h.link_to("Cancel", form.cancel_url, class_='button autodisable')}
|
${h.link_to("Cancel", form.cancel_url, class_='cancel button{}'.format(' autodisable' if form.auto_disable_cancel else ''))}
|
||||||
% endif
|
% endif
|
||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
|
|
Loading…
Reference in a new issue