So since a time field automatically has an IS_TIME validator how would you
specify additional validators after the db.define_table statement?
On Tuesday, November 12, 2013 3:51:12 AM UTC-5, Niphlod wrote:
>
> requires can be a list of validators.....
>
> On Tuesday, November 12, 2013 9:32:27 AM UTC+1, User wrote:
>>
>> Just realized I added the following lines after my db.define_table
>> statement:
>>
>> db.sometable.start_time.notnull = True
>> db.sometable.start_time.requires = IS_NOT_EMPTY()
>>
>>
>> I'm thinking that my assignment of IS_NOT_EMPTY() overwrote the default
>> IS_TIME() validator associated with time fields. Does this sound like what
>> the problem is? If so, how do I get around it?
>>
>> On Tuesday, November 12, 2013 3:24:36 AM UTC-5, User wrote:
>>
>>> I have some code that was working before but I can't quite pinpoint why
>>> it's not working now. In any case it's a time field in a table and when I
>>> insert into this field the database shows '00:00:00' in the field (by
>>> looking at the record in an SQLite admin tool)
>>>
>>> Field('start_time','time', default='2:00PM'),
>>>
>>> I have a form where this value is inserted along with other form
>>> values. The insert statement looks like:
>>>
>>> form.vars.id = db.sometable.insert(**db.sometable._filter_fields(form.
>>> vars))
>>>
>>>
>>> I have inspected form.vars in the debugger immediately before this
>>> statement is executed and I can see form.vars.start_time has a string value
>>> such as '3:00PM'. The insert statement executes with no error and the
>>> record is inserted in the database but the time field shows as
>>> 00:00:00. This further causes an error when trying to view the database
>>> record from web2py:
>>>
>>> ValueError: invalid literal for int() with base 10: '00PM'
>>>
>>>
>>> Any idea why the time is not inserting properly and how to fix it? Is
>>> the time string in the wrong format?
>>>
>>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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.