How to preset fields with crud.create()?

7 views
Skip to first unread message

Joe Barnhart

unread,
Feb 17, 2009, 8:50:59 PM2/17/09
to web2py Web Framework
I'm trying to use the new Crud features in 1.56 (coming from T2) but
I'm having difficulty porting my application. I need to create
entries in a table that refer to the logged-in user. Before, I just
preset the id field to the id of the current user, but I don't see a
way to do that with crud.create(). What am I missing?

mdipierro

unread,
Feb 17, 2009, 11:46:44 PM2/17/09
to web2py Web Framework
Try:

crud.create(db.table,onvalidation=lambda form:
form.vars.field='value')

OR

db.table.field.default='value'
crud.create(db.table)
Reply all
Reply to author
Forward
0 new messages