On Wednesday, February 6, 2013 8:24:01 AM UTC-5, Gerd wrote:
>
> Hi Annet and DenesL!
>
> @DenesL: Yes, did restart it, nothings changed
>
True. Note that the input will show HH:MM:SS until you click on it, then it
becomes HH:MM.
>
> @Annet: Thanks you very much, you got it
>
> regards
> Gerd
>
> Am Mittwoch, 6. Februar 2013 13:31:24 UTC+1 schrieb Annet:
>>
>> Hi Gerd,
>>
>> So if i understand this right there is no possibility to change the
>>> representation in an update form?
>>>
>>
>>
>> Yes, besides, I am not sure whether IS_TIME() has a format property like
>> IS_DATE() and IS_DATETIME() have.
>> In 2009 it hadn't, and Chris helped me solve the problem as follows:
>>
>> In db.py:
>>
>> istime = dict(type='time',requires=IS_TIME(error_message=T('no match
>> HH:MM')),widget=timeplain,comment=T('Format HH:MM'))
>>
>> Field('startTime',**istime),
>> Field('endTime',**istime),
>>
>> In a module:
>>
>> def timeplain(field,value):
>> if value == None:
>> value = ''
>> elif 'strftime' in dir(value):
>> value = value.strftime('%H:%M')
>> id = '%s_%s' % (field._tablename, field.name)
>> return INPUT(_type='text',_id=id,_class='time_plain',_name=field.name
>> ,value=str(value),requires=field.requires)
>>
>
The only caveat here is that you will not be using jQuery.timeEntry, unless
you change the class to just 'time'.
You can also do:
widget=lambda field,value: SQLFORM.widgets.time.widget(field,
value.strftime('%H:%M') if value else '')
but you still need to add {showSeconds:false} to .timeEntry in web2py.js
>
>> and in case you need it, in a view:
>>
>> {{=table.startTime.strftime("%H:%M")}}
>>
>>
>> Kind 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.