difference between fields= [] and Fields = []

4 views
Skip to first unread message

hamdy.a.farag

unread,
Oct 22, 2009, 10:57:34 PM10/22/09
to web2py-users
Hi,

supposing I've a function in my controller as follows

def new_recipe():
form = SQLFORM(db.recipe, fields= ['title','description'])
return dict(form=form)

which returns the form to the view where 2 fields are only seen by
user
my question is:

when I changed 'fields' to 'Fields', I got no complain and I got the
whole form in the view
so what's the point of using 'Fields' any way while I can just say
SQLFORM(db.recipe)?

Richard

unread,
Oct 22, 2009, 11:23:40 PM10/22/09
to web2py-users
SQLFORM(db.recipe) will create a form with all fields used in that
database table.
But if you want a form with only certain fields then you can use the
"fields" argument. For example some of the fields may need to be
calculated by you rather than entered manually by the user.

The "Fields" argument is not part of the API so will be ignored.

Richard

hamdy.a.farag

unread,
Oct 23, 2009, 12:21:49 AM10/23/09
to web2py-users
aha ... thank you
Reply all
Reply to author
Forward
0 new messages