Ahmed M Farrag
Ahmed M Farrag

Reputation:

how to generate a many-to-many-relationship FORM in web2py?

Do I need a custom validator? Do I need a custom widget?

If this helps to clear the problem, the relationship is between member and language where a member can have multiple languages and a language is spoken by multiple members.

I would like to add a multi-select box in the "add member" form (that I generate using SQLFORM).

Thanks :)

Upvotes: 2

Views: 1520

Answers (2)

rmontgomery429
rmontgomery429

Reputation: 14860

Another way to do this:

db.define_table( 'make', Field( 'name' ) )

db.define_table( 'model', 
    Field( 'name' ), 
    Field( 'make', db.make, requires = IS_IN_DB( db, 'make.id', '%(name)' ) ) )

Upvotes: 0

mdipierro
mdipierro

Reputation: 4248

It depends and I suggest you take this on the web2py mailin list. One way to do it is

db.table.field.requires=IS_IN_DB(db,'othertable.id','%(otherfield)',multiple=True)

Upvotes: 1

Related Questions