You should use IS_IN_DB for this IS_IN_DB(db(optional_subquery),table.field,"optional representation")
Because you do not want to create the set at every request even if not used. IS_IN_DB will do the query lazily. On Dec 30, 5:41 pm, Manu <[email protected]> wrote: > Basically i have some research papers that i would like to access from > my web2py application. Each paper have a title and one or many > authors. But i would like also to add keywords to these papers so that > i can quickly filter the ones i am interested in. > What i have done so far is: > > db.define_table('documents', > Field('title'), > Field('author'), > Field('category', list:string, requires=IS_IN_SET(['computer', > 'mathematics'], multiple=True), > ) > > I would like to replace ['computer', 'mathematics'] by something more > dynamic , that come from another table called categories for ex . How > to do that ? Furthermore i would like to be able to generate a form > from the SQLFORM helper that will show me a list of categories and > allow me to select multiple items. > > How would you advise me to do that ? Is there the right validators > already in the code or should I write mine ? > > Thx > > On Thu, Dec 30, 2010 at 11:03 PM, mdipierro <[email protected]> wrote: > > I was mistaken. I misunderstood. I am still not sure I understand. Can > > you make an example? > > > On Dec 30, 2:04 pm, mdipierro <[email protected]> wrote: > >> this is not currently supported. > > >> On Dec 30, 1:20 pm, Manu <[email protected]> wrote: > > >> > Hi , > > >> > I have a database which contains a list:string field type and a > >> > requirement to be in a set of value ( with IS_IN_SET AND multiple=True > >> > ) . My question is how would you dynamically generate this set( my > >> > categories are stored in another table ) ? What i am trying to do is > >> > to allow user to select many categories ( yes this field is a category > >> > ) at the same time . IS-IN_DB does not work because it seems we cqn't > >> > select many choice. > > >> > Do you use SQLFORM.factory , create the form manually or is there some > >> > special trick to pass this set > > >> > Thx > >

