From 0f5d668f8647addb3ce7fa9b3d8c5686edfb27fe Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 22 Feb 2019 20:46:54 -0600 Subject: [PATCH] Add "plain" date widget to avoid deform.addCallback() JS for mobile forms surely there's a better solution, but this works for now... --- tailbone/forms/core.py | 4 +++- tailbone/forms/widgets.py | 4 ++++ tailbone/templates/deform/date_plain.pt | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tailbone/templates/deform/date_plain.pt diff --git a/tailbone/forms/core.py b/tailbone/forms/core.py index 2ecdbb5c..ceda975f 100644 --- a/tailbone/forms/core.py +++ b/tailbone/forms/core.py @@ -48,7 +48,7 @@ from webhelpers2.html import tags, HTML from tailbone.util import raw_datetime from . import types -from .widgets import ReadonlyWidget, JQueryDateWidget, JQueryTimeWidget +from .widgets import ReadonlyWidget, PlainDateWidget, JQueryDateWidget, JQueryTimeWidget log = logging.getLogger(__name__) @@ -570,6 +570,8 @@ class Form(object): self.set_renderer(key, self.render_datetime) elif type_ == 'datetime_local': self.set_renderer(key, self.render_datetime_local) + elif type_ == 'date_plain': + self.set_widget(key, PlainDateWidget()) elif type_ == 'date_jquery': # TODO: is this safe / a good idea? # self.set_node(key, colander.Date()) diff --git a/tailbone/forms/widgets.py b/tailbone/forms/widgets.py index b90f9dda..ddb71b78 100644 --- a/tailbone/forms/widgets.py +++ b/tailbone/forms/widgets.py @@ -96,6 +96,10 @@ class JQuerySelectWidget(dfwidget.SelectWidget): template = 'select_jquery' +class PlainDateWidget(dfwidget.DateInputWidget): + template = 'date_plain' + + class JQueryDateWidget(dfwidget.DateInputWidget): """ Uses the jQuery datepicker UI widget, instead of whatever it is deform uses diff --git a/tailbone/templates/deform/date_plain.pt b/tailbone/templates/deform/date_plain.pt new file mode 100644 index 00000000..b473e422 --- /dev/null +++ b/tailbone/templates/deform/date_plain.pt @@ -0,0 +1,16 @@ +
+ ${field.start_mapping()} + + ${field.end_mapping()} +