Thank you for detailed answer I am trying to implement this in SQLFORM? Looks like multiple option is not avaliable, the field is presented as text field in the form
BTW - why web2py does not add new field to a table. If I set migrate to True I get an error "table already exists" if it is set to false new fields were not created so I had to create them manually ?? Thank you 2015-08-07 19:10 GMT+08:00 Lisandro <rostagnolisan...@gmail.com>: > Hi there. > Web2py has some cool field types called "list:string", "list:integer" and > "list:reference table". Check them here: > > http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-types > > In your case, you could avoid the creation of the third table with > *list:reference > table*, for example, in your db.py: > > db.define_table('skill', Field('name')) > > db.define_table('worker',\ > Field('name'),\ > Field('skills','list:reference skill')) > > > Then you can do things like: > > skill_1 = db.skill.insert(name='coding in python') > skill_2 = db.skill.insert(name='making a cake') > skill_3 = db.skill.insert(name='writing a song') > > db.worker.insert(name='John', skills=[skill_1, skill_2]) > db.worker.insert(name='Paul', skills=[skill_3]) > db.worker.insert(name='Richard', skills=[skill_2, skill_3]) > > # search which workers have skill_2: > have_skill_3 = db(db.worker.skills.contains(skill_2)).select() > > > The list:reference field will be rendered as a select with multiple=True. > You can always write your own widget to use other stuff, like checkboxes. > > Look for "list:reference" in this group, you will lots of posts about it. > Hope it helps! > > > > El jueves, 6 de agosto de 2015, 22:51:53 (UTC-3), Yebach escribió: >> >> Hello >> >> How to solve the problem of one to many relationship: >> >> Lets say I have a worker that has multiple skills. How to set up SQLFORM >> to add as many skills to the worker as possible. >> >> So skills in one table workers in another.I guess a third table will be >> needed >> >> Thank you >> >> best regards >> > -- > 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/HjhQdAZWFWY/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Lep pozdrav Vid Ogris -- 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.