Is there way create interaction between two selects in SQLFORM. I have these tables in *tables.py*: db.define_table( 'categories', Field('PRIORITY','integer'), migrate=False)
db.define_table( 't_categories_names', Field('ID_CATEGORY','reference categories',writable=False,readable=False ), Field('LANGUAGE','reference languages'), Field('NAME',length=30), primarykey=['ID_CATEGORY'], migrate=False) db.define_table( 'subcategories', Field('ID_CATEGORY','reference categories'), migrate=False) db.define_table( 't_subcategories_names', Field('ID_SUBCATEGORY','reference subcategories'), Field('LANGUAGE','reference languages'), Field('NAME',length=30,unique=True), primarykey=['ID_SUBCATEGORY'], migrate=False) db.define_table( 'recipes', Field('ID_SUBCATEGORY','reference subcategories'), Field('IMAGE','upload'), migrate=False) I use SQLFORM with extra field for 'category' in controller default.py: def addRecipe(): db.recipes.ID_SUBCATEGORY.requires = IS_IN_DB(db((db. t_subcategories_names.ID_SUBCATEGORY == db.subcategories.id) & (db. t_subcategories_names.LANGUAGE == auth.user.language)),db. t_subcategories_names.ID_SUBCATEGORY,'%(NAME)s') categories = {rec.categories.id:rec.t_categories_names.NAME for rec in db((db.categories.id == db.t_categories_names.ID_CATEGORY) & (db. t_categories_names.LANGUAGE == auth.user.language)).select(db.categories.id, db.t_categories_names.NAME,orderby=db.categories.PRIORITY)} form = SQLFORM(db.recipes,fields=['ID_SUBCATEGORY','IMAGE'],labels = { 'ID_SUBCATEGORY':T('Subcategory'),'IMAGE':T('Image')}) my_extra_element = DIV( LABEL( T('Category'), _class='form-control-label col-sm-3' ), DIV( SELECT( *[OPTION(value_, _value=key_) for key_, value_ in iter( categories.items())], _class='form-control' ), _class='col-sm-9' ), _class='form-group row' ) form[0].insert(0,my_extra_element) if form.process().accepted: response.flash='Thanks for filling the form' return dict(form=form) I have result like on picture. As you can see if user have choosen 'Drinks' select with subcategory contain all names for all categories. P.S. I can do interaction between two selects with jquery, but I want to know is there way do it with web2py tools like widget maybe with autocomplete or options.widget. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/5c38b608-088c-43e4-b9fc-9841a4cdfeff%40googlegroups.com.