Add Form.mobile flag and set link button styles accordingly

This commit is contained in:
Lance Edgar 2018-02-22 11:12:51 -06:00
parent 046a70c5f6
commit ff7341d272
2 changed files with 7 additions and 2 deletions

View file

@ -327,7 +327,7 @@ class Form(object):
auto_disable_save = True auto_disable_save = True
auto_disable_cancel = 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, mobile=False, 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,
hidden={}, widgets={}, defaults={}, validators={}, required={}, helptext={}, hidden={}, widgets={}, defaults={}, validators={}, required={}, helptext={},
action_url=None, cancel_url=None): action_url=None, cancel_url=None):
@ -339,6 +339,7 @@ class Form(object):
if self.fields is None and self.schema: if self.fields is None and self.schema:
self.set_fields([f.name for f in self.schema]) self.set_fields([f.name for f in self.schema])
self.request = request self.request = request
self.mobile = mobile
self.readonly = readonly self.readonly = readonly
self.readonly_fields = set(readonly_fields or []) self.readonly_fields = set(readonly_fields or [])
self.model_instance = model_instance self.model_instance = model_instance

View file

@ -80,7 +80,11 @@ ${h.csrf_token(request)}
<input type="reset" value="Reset" /> <input type="reset" value="Reset" />
% endif % endif
% if getattr(form, 'show_cancel', True): % if getattr(form, 'show_cancel', True):
${h.link_to("Cancel", form.cancel_url, class_='cancel button{}'.format(' autodisable' if form.auto_disable_cancel else ''))} % if form.mobile:
${h.link_to("Cancel", form.cancel_url, class_='ui-btn ui-corner-all')}
% else:
${h.link_to("Cancel", form.cancel_url, class_='cancel button{}'.format(' autodisable' if form.auto_disable_cancel else ''))}
% endif
% endif % endif
</div> </div>
% endif % endif