Thanks very much Anthony, I didn't know this feature.
2012/5/31 Anthony <[email protected]>: > db.class_attendant.person_id.requires = IS_IN_DB(db(db.person.age >= 18), > > 'person.id', '%(name)s %(surname)s') > > The first argument to IS_IN_DB and IS_NOT_IN_DB can be a Set object rather > than an entire db connection. > See http://web2py.com/books/default/chapter/29/7#Database-validators. > > Anthony > > > On Thursday, May 31, 2012 2:49:35 PM UTC-4, José L. wrote: >> >> Hi, I'm using a referenced table with IS_IN_DB validator, but I'd like to >> filter the fields to be shown in the combo list. >> As an example: >> >> db.define_table('person', >> Field('name'), >> Field('surname), >> Field(age,'integer') >> ) >> >> db.define_table('class_attendant', >> Field('Date','date'), >> Field('Classname'), >> Field('person_id',db.person,readable=True,writable = True, >> label="User")) >> >> db.class_attendant.person_id.requires = IS_IN_DB(db,'person.id','%(name)s >> %(surname)s') >> >> When using a SQLFORM(db.class_attendant) to add new persons to the >> class_attendant table, the combo list shows all the persons in the person >> table, but I'd like it to show only the persons whose age is upper than 18. >> What's the best method to do it? >> >

