Add "plain" date widget
to avoid deform.addCallback() JS for mobile forms surely there's a better solution, but this works for now...
This commit is contained in:
parent
4b3e1c7b1b
commit
0f5d668f86
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
|
16
tailbone/templates/deform/date_plain.pt
Normal file
16
tailbone/templates/deform/date_plain.pt
Normal file
|
@ -0,0 +1,16 @@
|
|||
<div tal:define="css_class css_class|field.widget.css_class;
|
||||
oid oid|field.oid;
|
||||
style style|field.widget.style;
|
||||
type_name type_name|field.widget.type_name;"
|
||||
tal:omit-tag="">
|
||||
${field.start_mapping()}
|
||||
<input type="${type_name}"
|
||||
name="date"
|
||||
value="${cstruct}"
|
||||
|
||||
tal:attributes="class string: ${css_class or ''} form-control hasDatepicker;
|
||||
style style;
|
||||
attributes|field.widget.attributes|{};"
|
||||
id="${oid}"/>
|
||||
${field.end_mapping()}
|
||||
</div>
|
Loading…
Reference in a new issue