mind that "end" is a keyword in sql and you can have problems with a
field called "end".

On Apr 22, 12:34 pm, pbreit <pbreitenb...@gmail.com> wrote:
> I think you were on the right track. I think naming the field "from" might
> have been a problem. I assume with your last function you had renamed the
> fields from_date and to_date? The if request.function might not be
> necessary. Remember that any functions with parameters cannot be accessed
> from the browser.
>
> This works OK:
>
> db.define_table('duration',
>     Field('start', 'datetime'),
>     Field('end', 'datetime'))
>
> def process_duration_form(form):
>     if form.vars.start > form.vars.end:
>         form.errors.start = 'start must be before end'
>
> def duration():
>     form = SQLFORM(db.duration)
>     if form.accepts(request.vars, session,
> onvalidation=process_duration_form):
>         response.flash = 'form accepted'
>     elif form.errors:
>         response.flash = 'form has errors'
>     else:
>         response.flash = 'please fill out the form'
>     return dict(form=form)

Reply via email to