The 'requires' attribute of a field has to be a validator or list of validators (validators are callable objects), not just any boolean test. I think you'll need a custom validator: http://web2py.com/book/default/chapter/07#Custom-Validators. You might also consider using an 'onvalidation' function with your form: http://web2py.com/book/default/chapter/07#onvalidation. Anthony On Friday, April 22, 2011 3:35:22 AM UTC-4, 黄祥 wrote:
> hi, > > is it possible to compare db field datetime during form validation? > e.g. > db.define_table('duration', > Field('from', > 'datetime', > requires = IS_DATE() > ), > Field('to', > 'datetime', > requires = [IS_DATE(), > request.vars.from < request.vars.to] > ) > ) > > an error occured said: > TypeError: 'bool' object is not callable > > also i tried: > > db.define_table('duration', > Field('from', > 'datetime', > requires = IS_DATE() > ), > Field('to', > 'datetime', > requires = [IS_DATE(), > form.vars.from < form.vars.to] > ) > ) > > an error occured said : > NameError: name 'form' is not defined > > does anyone have a clue to solve it? > > thank you very much for your kind attention