Let forms choose *not* to auto-disable their cancel button

This commit is contained in:
Lance Edgar 2018-02-07 20:06:35 -06:00
parent 00a3b8fc33
commit c35bfa3e4e
2 changed files with 5 additions and 2 deletions

View file

@ -324,6 +324,8 @@ class Form(object):
update_label = "Save"
show_cancel = 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=[],
model_instance=None, model_class=None, nodes={}, enums={}, labels={}, renderers=None,
@ -687,7 +689,8 @@ class Form(object):
context['form'] = self
context['dform'] = dform
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['request'] = self.request
context['readonly_fields'] = self.readonly_fields

View file

@ -77,7 +77,7 @@ ${h.csrf_token(request)}
## ${h.submit('create_and_continue', form.successive_create_label)}
## % endif
% 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
</div>
% endif