Hi Annet,
to make the widget safer we could do:
timewidget=lambda field,value: TAG[''](SQLFORM.widgets.time.widget(field,
value.strftime('%H:%M') if hasattr(value,'strftime') else '',
_class='mytime'),script)
but I still don't understand how you can submit a value of 09:
that input is just not possible.
Are you sure that jQuery.timeEntry is working?.
Regards,
Denes
On Thursday, February 7, 2013 1:33:05 PM UTC-5, Annet wrote:
>
> Hi Denes,
>
>
>
>>> I no longer get the error message when a user enters for example 09: so
>>> only the hours not the minutes. How would I have to adjust your code to
>>> validate the time?
>>>
>>
>> It should not be possible to enter just 09: , jQuery.timeEntry will not
>> allow that to happen.
>> It only allows numeric input and pads it with zeros.
>> Your code works fine on my trunk test system.
>>
>
> On my system submitting the form with startTime 09: I get the following
> error:
>
> Traceback (most recent call last):
> File "/Users/annet/web2py/gluon/restricted.py", line 212, in restricted
> exec ccode in environment
> File "/Users/annet/web2py/applications/init/controllers/cmscalendar.py"
> <http://127.0.0.1:8000/admin/edit/init/controllers/cmscalendar.py>, line 291,
> in <module>
> File "/Users/annet/web2py/gluon/globals.py", line 188, in <lambda>
> self._caller = lambda f: f()
> File "/Users/annet/web2py/gluon/tools.py", line 2912, in f
> return action(*a, **b)
> File "/Users/annet/web2py/applications/init/controllers/cmscalendar.py"
> <http://127.0.0.1:8000/admin/edit/init/controllers/cmscalendar.py>, line 71,
> in openingHours
>
> form.process(onvalidation=onvalidation_openinghours,onsuccess=onsuccess_message,next=URL('openingHours'))
> File "/Users/annet/web2py/gluon/html.py", line 2170, in process
> self.validate(**kwargs)
> File "/Users/annet/web2py/gluon/html.py", line 2109, in validate
> if self.accepts(**kwargs):
> File "/Users/annet/web2py/gluon/sqlhtml.py", line 1321, in accepts
> widget = field.widget(field, value)
> File "/Users/annet/web2py/applications/init/models/10_table_db.py"
> <http://127.0.0.1:8000/admin/edit/init/models/10_table_db.py>, line 24, in
> <lambda>
> timewidget=lambda field,value: TAG[''](SQLFORM.widgets.time.widget(field,
> value.strftime('%H:%M') if value else '', _class='mytime'),script)
> AttributeError: 'str' object has no attribute 'strftime'
>
>
> In case I enter startTime 09:00, I don't get the error.
>
> Best Regards,
>
> Annet
>
>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.