plone.app.z3cform/thet-dateinputtype: Change the input type for date fields to date and for dateti

Johannes Raggam <jenkins-z4DKO/[email protected]>
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: plone.app.z3cform
Branch: refs/heads/thet-dateinputtype
Date: 2017-07-14T12:34:16+02:00
Author: Johannes Raggam (thet) <[email protected]>
Commit: https://github.com/plone/plone.app.z3cform/commit/8da3880bdd6fd476c5b2fbab4dc903aa7b9b367b

Change the input type for date fields to date and for datetime fields to datetime-local.

Files changed:
M CHANGES.rst
M plone/app/z3cform/widget.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 9cf4569..e056fba 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -10,7 +10,8 @@ Breaking changes:
 
 New features:
 
-- *add item here*
+- Change the input type for date fields to ``date`` and for datetime fields to ``datetime-local``.
+  [thet]
 
 Bug fixes:
 
diff --git a/plone/app/z3cform/widget.py b/plone/app/z3cform/widget.py
index 0409d44..de04d37 100644
--- a/plone/app/z3cform/widget.py
+++ b/plone/app/z3cform/widget.py
@@ -128,6 +128,7 @@ class DateWidget(BaseWidget, HTMLInputWidget):
     _formater = 'date'
 
     pattern = 'pickadate'
+    # pattern = 'date-picker'
     pattern_options = BaseWidget.pattern_options.copy()
 
     def _base_args(self):
@@ -146,6 +147,7 @@ def _base_args(self):
         args['name'] = self.name
         args['value'] = (self.request.get(self.name,
                                           self.value) or u'').strip()
+        args['type'] = 'date'
 
         args.setdefault('pattern_options', {})
         if self.field.required:
@@ -220,6 +222,8 @@ def _base_args(self):
         if args['value'] and len(args['value'].split(' ')) == 1:
             args['value'] += ' 00:00'
 
+        args['type'] = 'datetime-local'
+
         args.setdefault('pattern_options', {})
         if 'time' in args['pattern_options']:
             # Time gets set in parent class to false. Remove.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.