Thanks Jim! Wonder how that escaped me. :)
On Dec 10, 12:21 am, Jim Steil <j...@qlf.com> wrote: > Not tested, but I'd do something like this... > > #controller > def new_tank(): > db.container.type.writable = False > db.container.type.readable = False > db.container.type.default = 'tank' > form = SQLFORM(db.container) > if form.process().accepted: > response.flash = 'New Question Successful' > elif form.errors: > response.flash = 'Oops there are errors' > return dict(form=form) > > On 12/9/2011 9:53 AM, lyn2py wrote: > > > > > > > > > For the code: > > > #model > > db.define_table('container', > > Field('type','string',requires=IS_IN_SET(['cup','bowl','tank'])), > > Field('title', 'string', length=255) > > Field('description', 'text'), > > ) > > > #controller > > def new_tank(): > > form = SQLFORM(db.container) > > if form.process().accepted: > > response.flash = 'New Question Successful' > > elif form.errors: > > response.flash = 'Oops there are errors' > > return dict(form=form) > > > I want to set a default db.container.type in controller, in this case, > > "tank". > > i.e. the vars inserted into the db includes type="tank", but this is > > not shown to the user filling up the form (I don't want it to be > > tampered by the user). > > It is a fixed value for type (in another function, it takes a > > different fixed value) > > How can I do this with form.process() or form.accepts()? (or other > > better ways?) > > > Thanks!