Add Form.show_cancel
flag, for hiding that button
also use fields from schema by default, if fields not provided
This commit is contained in:
parent
22d9981c2e
commit
6cc509f5b4
|
@ -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 [])
|
||||
|
|
|
@ -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
|
||||
% if getattr(form, 'show_cancel', True):
|
||||
${h.link_to("Cancel", form.cancel_url, class_='button autodisable')}
|
||||
% endif
|
||||
</div>
|
||||
% endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue