Re: [web2py] Re: Adding information to certain input before added to db?

2014-06-09 Thread Fabiano Almeida
Other way is before and after callbacks http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks If necessary, you can call function: db.table1._before_insert.append( lambda f: my_function(f)) This way you do not need to manually enter the registry

[web2py] Re: Adding information to certain input before added to db?

2014-06-09 Thread 黄祥
thank you so much for showing simpler version, anthony. best regards, stifan On Saturday, June 7, 2014 11:19:27 PM UTC+7, Anthony wrote: Aside from the code below, somewhat simpler approaches would be to manipulate request.post_vars *before* calling SQLFORM, or using an onvalidation

[web2py] Re: Adding information to certain input before added to db?

2014-06-07 Thread Anthony
Aside from the code below, somewhat simpler approaches would be to manipulate request.post_vars *before* calling SQLFORM, or using an onvalidation function (which allows you to change form.vars after validation but before the db insert). With those approaches, you don't have to manually do the

[web2py] Re: Adding information to certain input before added to db?

2014-06-06 Thread 黄祥
i think you can achieve it using form.validate : e.g. def booking(): form = SQLFORM(db.booking_header) if form.validate(): db.booking_header.insert(booking_date = form.vars.booking_date, buyer = form.vars.buyer,