Hi Massimo

Here is a patch which updates the date, time and datetime widget. If this 
approach is acceptable, I am happy to provide a patch for the other types 
as well.

Calvin

On Sunday, 30 December 2012 00:50:59 UTC+8, Massimo Di Pierro wrote:
>
> I think this would be a good idea but somebody should be in charge of 
> this. Perhaps we can take this approach for web3py where widgets will have 
> a simpler internal design. It will be possible to use web3py widgets in 
> web2py.
>
> Anybody wants to be in charge of this? I can explain more so we can 
> discuss options.
>
> Massimo
>
>
>

-- 



>From 4a4806d78aa18ea109b8c14e425d12cc3ed49071 Mon Sep 17 00:00:00 2001
From: Calvin Sim <[email protected]>
Date: Mon, 31 Dec 2012 01:56:23 +0800
Subject: [PATCH] updated date, time, datetime widget's type attribute to
 enable more specific inputs with compatible browsers.

---
 gluon/sqlhtml.py |   42 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py
index a5827e9..7f4423b 100644
--- a/gluon/sqlhtml.py
+++ b/gluon/sqlhtml.py
@@ -160,16 +160,56 @@ class DecimalWidget(StringWidget):
 class TimeWidget(StringWidget):
     _class = 'time'
 
+    @classmethod
+    def widget(cls, field, value, **attributes):
+        """
+        generates an INPUT time tag.
+
+        see also: :meth:`FormWidget.widget`
+        """
+
+        default = dict(_type='time', value=value)
+        attr = cls._attributes(field, default,
+                               **attributes)
+        return INPUT(**attr)
+
 
 class DateWidget(StringWidget):
     _class = 'date'
 
+    @classmethod
+    def widget(cls, field, value, **attributes):
+        """
+        generates an INPUT date tag.
+
+        see also: :meth:`FormWidget.widget`
+        """
+
+        default = dict(_type='date', value=value)
+        attr = cls._attributes(field, default,
+                               **attributes)
+        return INPUT(**attr)
+
 
 class DatetimeWidget(StringWidget):
     _class = 'datetime'
 
 
-class TextWidget(FormWidget):
+classssmethod
+    def widget(cls, field, value, **attributes):
+        """
+        generates an INPUT datetime tag.
+
+        see also: :meth:`FormWidget.widget`
+        """
+
+        default = dict(_type='datetime', value=value)
+        attr = cls._attributes(field, default,
+                               **attributes)
+        return INPUT(**attr)
+
+
+ TextWidget(FormWidget):
     _class = 'text'
 
     @classmethod
-- 
1.7.10.2 (Apple Git-33)

Reply via email to