web2py will only store the key part (1,2,.. or 5) in the category field. You have to provide the value part for the key:value pairs.
courses = {1:'Arte',2:'Artigianato',3:'Cucina',4:'sport',5:'informatica'} db.courses.category.requires = IS_IN_SET(courses, zero='Scegli la categoria' ) # it can be set dynamically <div>{{=courses[course.category]}}</div> Note that you have to include the courses dictionary in your return so it is available to the view or define it in a model. Denes On Saturday, January 23, 2016 at 1:36:02 PM UTC-5, Fabio Ceccarani wrote: > > Hi all, > I create a field with requires=IS_IN_SET where list of values is a > dictionary: > > db.define_table('courses', > ... > Field('category',requires=IS_IN_SET({1:'Arte',2:'Artigianato',3:'Cucina' > ,4:'sport',5:'informatica'},zero='Scegli la categoria')) > ...) > > > In default.py *result* function return result of a query in *courses* > variable used by* results.html*. > In view file *results.html* I retrieve it with: > > {{for course in courses:}} > ... > <div>{{=course.category}}</div> > ... > {{pass}} > > but so I can retrieve only key (1,2,3,4,...). > How can I retrieve values ('Arte','Artigianato',...)? > > Thanks > Fabio > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.