i need to validate a field based on an external read-only database (i call it gdb)
there are four tables that are related by their own codes gdb.r_table.code gdb.p_table.code gdb.t_table.code gdb.v_table.code I have no use for the the id field of each table. Each table has, among others: r_table.code is unique but r_table.name may not be so. p_table.code is unique but p_table.name may not be. t_table.code is uniquely composed of r_table.code + p_table.code. t_table.name may not be unique. v_table-code is uniquely composed of t.table-code+serial numbers v_table.name may not be unique. In my app database, I only need to store the v_table-code since I can programatically find out what the other codes are from it. But for the convenience of the user (who is probably unaware of the codes), I need to present a selection list of v_table.names based on choices they made from p_table.name and t_table.name. There are 100 records in p_table, 1,500 in t_table and 40,000 in v_table. What's the best way to do this? I thought that I could populate a variable with the list of each p_list = gdb(gdb.select(gdb.p_table.code, gdb.p_table_name)) t_list = gdb(gdb.select(gdb.t_table.code, gdb.t_table_name)) v_list = gdb(gdb.select(gdb.v_table.code, gdb.v_table_name)) # prolly not a good idea to retrieve all 40,000 but .... then in the requires argument of each field form = SQLFORM.factory( # snip. other fields here Field('p', requires = [IS_NOT_EMPTY(), IS_IN_SET(p_list)), # this works Field('t', requires = [IS_NOT_EMPTY(), IS_IN_SET(t_list)), # how to trigger controller to present a sublist of t_list Field('v', requires = [IS_NOT_EMPTY(), IS_IN_SET(v_list)) # how to trigger controller to present a sublist of v_list # snip. other fields here) Above works but no validation is enforced. (i.e. a user can select a 'v' that is not actually a member of his/her 't' selection) How can i trigger a controller that will filter t_list based on selection made on 'p' field, and another controller to do the same for v_list based on 'T' selection from t_list. thanks.