Yes. By default, a reference field gets a validator like this: IS_IN_DB(db, db.sometable._id, db.sometable._format). However, the IS_IN_DB() validator can take a Set object as the first argument instead of db, and the list will be based on the records defined by that Set. In that case, you'll have to explicitly define the validator:
requires=IS_IN_DB(db([your query]), db.sometable.id, db.sometable._format) Note, when you define your own validator, you also lose the automatic "represent" attribute for the reference field, so you might want to set your own: represent=db.sometable._format Anthony On Tuesday, August 28, 2012 12:28:10 PM UTC-4, lyn2py wrote: > > Hello experts, > > Generally, when we do a SQLFORM, the 'reference table' fields > automatically gets *all* the available options for choosing as a dropdown > menu. > > However, I would like to get a filtered list instead of *all* of the > items. Is there an available function I can use to achieve a filtered list > for choosing in the dropdown menu? > > Another way to look at this is: > I would like to generate a SELECT/OPTIONS html using a specific query, > i.e. it uses the retrieved Rows to generate the HTML. I wonder if there is > a function in web2py for doing this. > > I hope my question is understood. Thank you. > > > PS. If there isn't an available function, I appreciate any tips or > pointers how I can make this work. Thanks! > --

