[web2py] How to to get SQLFORM.factory to show only a subset of records ?

2011-07-13 Thread Mike Veltman
This will probably a facepalm moment but I can not figure it out. My present used form function form = SQLFORM.factory( Field('setup', requires=IS_IN_DB(db, db.setup.setupname, '%(setupname)s') )) Model db.define_table('setup', Field('setupname', type='string',

Re: [web2py] How to to get SQLFORM.factory to show only a subset of records ?

2011-07-13 Thread Anthony
IS_IN_DB takes a DAL set, so you can limit the records returned. If you want the record ID returned, use db.setup.id. So, maybe something like this: Field('setup', requires=IS_IN_DB(db(db.setup.ready==True), db.setup.id, '%(setupname)s')) Anthony On Wednesday, July 13, 2011 9:06:03 PM

Re: [web2py] How to to get SQLFORM.factory to show only a subset of records ?

2011-07-13 Thread Anthony
For reference, see http://web2py.com/book/default/chapter/07#Database-Validators. On Wednesday, July 13, 2011 9:21:54 PM UTC-4, Anthony wrote: IS_IN_DB takes a DAL set, so you can limit the records returned. If you want the record ID returned, use db.setup.id. So, maybe something like

Re: [web2py] How to to get SQLFORM.factory to show only a subset of records ?

2011-07-13 Thread Anthony
Oh, and to get rid of the empty choice at the top of the list, add zero=None: IS_IN_DB(..., zero=None) On Wednesday, July 13, 2011 9:22:50 PM UTC-4, Anthony wrote: For reference, see http://web2py.com/book/default/chapter/07#Database-Validators. On Wednesday, July 13, 2011 9:21:54

Re: [web2py] How to to get SQLFORM.factory to show only a subset of records ?

2011-07-13 Thread Mike Veltman
Thanks about 1 zillion times :) Oh, and to get rid of the empty choice at the top of the list, add zero=None: IS_IN_DB(..., zero=None) On Wednesday, July 13, 2011 9:22:50 PM UTC-4, Anthony wrote: For reference, see http://web2py.com/book/default/chapter/07#Database-Validators.