Using IS_IN_DB to do record lookup validation
[edit]Consider:
db.recipe.category.requires=IS_IN_DB(db,'category.id','category.name')
The parameters are:
- a set of records
category.iddescribes how the field will be represented in the databasecategory.namedescribes how the field will be represented to the user
For example you can do things like:
requires=IS_IN_DB(db(db.category.name.like('d%')),
'category.id',
'Name: %(name)s, id: %(id)s any text your like')
Comments
Fred on 2008-04-22 14:21:26 says
That works great. I'm using "%(last_name)s, %(first_names)s" for the third parameter when defining a foreign key to a table of people's names. [inappropriate?]
That works great. I'm using "%(last_name)s, %(first_names)s" for the third parameter when defining a foreign key to a table of people's names. [inappropriate?]