The definition:

db.define_table("navrae",
    Field("begindatum", "date", default=None),
    Field("einddatum", "date", default=None),
    Field("gebruiker", "string", length=8, notnull=True, default='NULL'),
    Field("ipadres", "string", length=15, notnull=True, default='NULL'),
    Field("datum_van_navraag", "datetime", default=None),
    Field("navraag_deur_wie", "string", default=None))


I want to check two things in this form:

begindatum =< einddatum
Only one of gebruiker and ipadres may be used.

I have tried unsucessfully accessing the variables in the function like this:

    if response.vars.begindatum > response.vars.einddatum:
        message = T("end date before start date")

and

    if form.vars.begindatum > response.vars.einddatum:
        message = T("end date before start date")

and

    if begindatum > einddatum:
        message = T("end date before start date")

But none of those variables are available.  When I try
form = SQLFORM(db.navrae)
    message = T("form has errors")
    if request.vars.begindatum > request.vars.einddatum:
        message = T("end date before start date")
        form.errors == True
    if form.errors:
        response.flash = message
    elif form.accepts(request.vars, session):
        form.vars.id = db.navrae.insert(**dict(form.vars))
        response.flash = 'form accepted'
    else:
        response.flash = 'please fill out the form'

I get no error message and the form is accepted even when einddatum <
begindatum.

I also tried this in the model:

db.navrae.einddatum.requires= (db.navrae.einddatum >= db.navrae.begindatum)

but get a TypeError: 'Query' object is not callable

So how do I do it?
-- 
"Finally, brethren, whatsoever things are true,  whatsoever things are
honest, whatsoever things are  just, whatsoever things are pure,
whatsoever things are lovely, whatsoever things are of good report; if
there be any virtue, and if there be any praise, think on these
things."    Philippians 4:8


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en

Reply via email to