Possible to pre-populate Crud form?

81 views
Skip to first unread message

hswolff

unread,
Aug 28, 2010, 3:01:31 PM8/28/10
to web2py-users
Hello all-
First time poster. Been hacking together my first web2py webapp for
the past two weeks. I've doing my best to find my questions through
searches however I can't seem to find an answer to this question:

I'm currently using Crud.create to create my new submission form on my
webapp. The model for my submission table is basic, however one field
is a set of either 'best' or 'worst'.

In my view I need to have one form that is pre-populated with the
value of 'best' and not shown to the end-user, and one pre-populated
with the value of 'worst'.

Is this possible to do with Crud or should I just use SQLFORM ?

-Harry

p.s: i am loving web2py. thank you mdipierro for all your hard work!

mdipierro

unread,
Aug 29, 2010, 1:09:30 AM8/29/10
to web2py-users
Welcome

yes you can do this:

db.mytable.myfield.default='best'
db.mytable.myfield.writable=False # user cannot change it
db.mytable.myfield.readable=False # user does not see it

before form=crud.create(db.mytable)
Reply all
Reply to author
Forward
0 new messages