diff --git a/tailbone/forms2/core.py b/tailbone/forms2/core.py index 3c0a2a17..d5b3cb81 100644 --- a/tailbone/forms2/core.py +++ b/tailbone/forms2/core.py @@ -321,6 +321,7 @@ class Form(object): Base class for all forms. """ update_label = "Save" + show_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, @@ -331,6 +332,8 @@ class Form(object): if fields is not None: self.set_fields(fields) self.schema = schema + if self.fields is None and self.schema: + self.set_fields([f.name for f in self.schema]) self.request = request self.readonly = readonly self.readonly_fields = set(readonly_fields or []) diff --git a/tailbone/templates/forms2/deform.mako b/tailbone/templates/forms2/deform.mako index d30113d6..ce8a73d0 100644 --- a/tailbone/templates/forms2/deform.mako +++ b/tailbone/templates/forms2/deform.mako @@ -76,7 +76,9 @@ ${h.csrf_token(request)} ## % if form.creating and form.allow_successive_creates: ## ${h.submit('create_and_continue', form.successive_create_label)} ## % endif - ${h.link_to("Cancel", form.cancel_url, class_='button autodisable')} + % if getattr(form, 'show_cancel', True): + ${h.link_to("Cancel", form.cancel_url, class_='button autodisable')} + % endif % endif