Display IS_IN_SET() label

28 views
Skip to first unread message

annet

unread,
Aug 25, 2010, 2:58:05 AM8/25/10
to web2py-users
In a controller I defined a form:

form=SQLFORM.factory(Field('bedrijf',requires=IS_IN_SET([2,3,4,5,6,7],labels=['Fitnesscentrum','Fysiofitnesscentrum','Personal
Trainer','Dietist(e)','Voedingsconsulent(e)','Yogaschool'],zero=None)))

In the view I would like to display the label of the selected option,
is this possible?


Kind regards,

Annet.

jeff

unread,
Aug 25, 2010, 4:40:03 AM8/25/10
to web2py-users
Wuth SQLFORM.factory, the way to do that is to use the default arg the
Field.

annet

unread,
Aug 25, 2010, 9:49:39 AM8/25/10
to web2py-users
Hi Jeff,

Thanks for your reply. Could you please provide me with the correct
syntax to solve this problem?


Kind regards,

Annet

mdipierro

unread,
Aug 25, 2010, 9:53:39 AM8/25/10
to web2py-users
form=SQLFORM.factory(Field('bedrijf',requires=IS_IN_SET([2,3,4,5,6,7],labels=['Fitnesscentrum','Fysiofitnesscentrum','Personal
Trainer','Dietist(e)','Voedingsconsulent(e)','Yogaschool'],zero=None),default=3))

annet

unread,
Aug 25, 2010, 11:06:11 AM8/25/10
to web2py-users
Massimo,

I am not sure you did understand my question correctly.

When in the form the user selects 'Fitnesscentre' in the drop box, the
function that selects all the Fitnesscentres takes 2 as its argument.
I would like the flash in the view to display something like:

"Fitnesscentres in Amsterdam"

request.vars.city gives me Amsterdam, what I am looking for is
something similar for Fitnesscentres, however, request.vars.bedrijf
gives me 2.


Kind regards,

Annet
Reply all
Reply to author
Forward
0 new messages