From c35bfa3e4e1dbd9a040c9a0d0e9b4f601d50dd76 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 7 Feb 2018 20:06:35 -0600 Subject: [PATCH] Let forms choose *not* to auto-disable their cancel button --- tailbone/forms2/core.py | 5 ++++- tailbone/templates/forms2/deform.mako | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tailbone/forms2/core.py b/tailbone/forms2/core.py index 263a791d..faf2c7ca 100644 --- a/tailbone/forms2/core.py +++ b/tailbone/forms2/core.py @@ -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 diff --git a/tailbone/templates/forms2/deform.mako b/tailbone/templates/forms2/deform.mako index ee70917e..3dcbbfaf 100644 --- a/tailbone/templates/forms2/deform.mako +++ b/tailbone/templates/forms2/deform.mako @@ -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 % endif