look here http://web2py.com/books/default/chapter/29/07#Database-validators
there are snippets that shows you how you can pass a query to the IS_IN_DB
validator
On Sunday, April 21, 2013 7:19:53 AM UTC+2, Alex Glaros wrote:
>
> What is the syntax for a full query for IS_IN_DB?
>
> In the example below, user's default email address is selected from a
> group all users' emails in table PartyEmailIntersection.
>
> User could have several emails in the table that contains everyone's
> emails.
>
> I only want that user's emails to appear in the drop down selection list,
> not all emails.
>
> 1. All emails are in table Email.
>
> 2. All users are in table Party.
>
> 4. All of the above emails are associated with their users in table
> PartyEmailIntersection.
>
> 5. PartyDefaultInfo table contains users' default email address. So a
> user can have many emails in PartyEmailIntersection table, but I want only
> that user's emails to appear in the drop-down selection, when populating
> PartyDefaultInfo table. Do not want to see all users' emails in the
> drop-down list.
>
> This IS_IN_DB validator works but displays a drop down of everyone's email
> address.
>
> db.PartyDefaultInfo.defaultEMailAddressID.requires = IS_IN_DB(db, db.
> PartyEmailIntersection.id, '%(eMailAddressID)s',zero=T('choose one'))
>
>
> What is the syntax for limiting drop-down list to only the user's emails
> (of which there are several)?
>
> thanks,
>
> Alex Glaros
>
> ##
> ---------------------------------------------------------------------------------------------
> db.define_table('Party', ## super-type for people and organizations
> Field('partyTypeID','reference PartyType'),
> Field('displayName','string'))
> ##
> ---------------------------------------------------------------------------------------------
> db.define_table('Email', ## A single person or organization can have many
> emails. Centralized location of all emails. Unique; no duplicates allowed.
> Field('eMailAddress','string'),
> Field('eMailTitle','string')) ## e.g., “main email for Alex”, or “help
> desk email address for Dept. of Motor Vehicles”
> ##
> ---------------------------------------------------------------------------------------------
> db.define_table('PartyEmailIntersection', ## A single person or
> organization can have many emails
> Field('partyID','reference Party'),
> Field('eMailAddressID','reference Email'))
> ##
> ---------------------------------------------------------------------------------------------
> db.define_table('PartyDefaultInfo',
> Field('partyID','reference Party'),
> Field('defaultEMailAddressID','reference Email'))
> ##
> ---------------------------------------------------------------------------------------------
>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.