That fixed it. Thanks Massimo. Is that behavior a design feature or just a quirk of implementation? :-) Mike
On Jul 2, 11:39 am, mdipierro <[email protected]> wrote: > field.requires = [IS_IN_DB(db,'%s.%s'%(tbname,fname))] > > no select > > field.requires = IS_IN_DB(db,'%s.%s'%(tbname,fname)) > > select > > On Jul 2, 9:46 am, MikeEllis <[email protected]> wrote: > > > (Note: there's a thread from last year on this subject, but for some > > reason it's only providing links to reply to author and not to the > > group) > > > The following model code is working correctly except that the > > generated SQLFORM has INPUT elements instead of select elements even > > though I've specifed an IS_IN_DB() requirement both as arguments to > > SQLField() and separately as a field.requires() statement. The > > validations work as expected for all fields in all tables, it's just > > the SELECT element that's missing. > > > The SQLFORM code is just > > form = SQLFORM(db.config) > > > and the view is > > {{=form}} > > > Here's the model code (db.py) > > > def configfields(): > > """ Here we define all the fields the user is expected to fill in > > during the configuration phase along with the tables that will > > be created to store all the allowed values for each field. > > > Returns {table:(field,type), ...} > > """ > > d = { > > 'users':('user_name','string'), > > 'boot':('boot_type','string'), > > 'ip':('base_device_ip','string'), > > 'port':('base_device_port','integer'), > > } > > return d > > > ## The config table records the user, boot, ip, and port used in > > ## each testing session. > > args = [] > > for tbname,(fname,ftype) in configfields().iteritems(): > > req = {'requires':IS_IN_DB(db,'%(tbname)s.%(fname)s'%locals())} > > args.append(SQLField(fname,ftype,**req)) > > > kwargs = {'migrate':True} > > db.define_table('config', *args, **kwargs) > > > for tbname,(fname,ftype) in configfields().iteritems(): > > ## These tables contain permitted values for the fields in > > ## the config table. > > db.define_table(tbname,SQLField > > (fname,ftype,unique=True),migrate=True) > > > ## create validation requirements such that the config table > > ## field values must be in the corresponding single field > > ## tables and that values entered in the single field tables > > ## must not be already present. > > table = getattr(db,tbname) > > field = getattr(table,fname) > > field.requires = [IS_NOT_IN_DB(db,'%s.%s'%(tbname,fname)), > > IS_NOT_EMPTY()] > > field = getattr(db.config,fname) > > field.requires = [IS_IN_DB(db,'%s.%s'%(tbname,fname))] > > > What am I doing wrong? > > > Thanks, > > Mike > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

