If inserts will be done via form submission, you can use an onvalidation
function, as Annet suggested, or you could do something like this:
db.define_table('payments',
Field('user_id', db.auth_user,
requires=IS_IN_DB(db, db.auth_user.id,
'%(last_name)s, %(first_name)s (%(id)s) |
%(email)s | %(city)s %(zip)s'),
writable=False, readable=False),
Field('firm_id', db.firms,
requires=IS_IN_DB(db, db.firms.id,
'%(firm_name)s (%(id)s) | %(city)s | %(zip)s |
%(telephone)s'),
writeable=False, readable=False),
...)
if request.vars.user_id:
db.payments.firm_id.requires = IS_EMPTY_OR(db.payments.firm_id.requires)
if request.vars.firm_id:
db.payments.user_id.requires = IS_EMPTY_OR(db.payments.user_id.requires)
Anthony
On Sunday, April 14, 2013 6:34:50 AM UTC-4, lucas wrote:
>
> ok, i had a little revelation in my sleep, have both fields IS_EMPTY_OR
> with IS_IN_DB, but how can i add the extra condition that one or the other
> must not be empty?
>
> db.define_table('payments',
> Field('user_id', db.auth_user, requires=IS_EMPTY_OR(IS_IN_DB(db,
> db.auth_user.id, '%(last_name)s, %(first_name)s (%(id)s) | %(email)s |
> %(city)s %(zip)s')), writable=False, readable=False),
> Field('firm_id', db.firms, requires=IS_EMPTY_OR(IS_IN_DB(db,
> db.firms.id, '%(firm_name)s (%(id)s) | %(city)s | %(zip)s |
> %(telephone)s')), writeable=False, readable=False),
>
>
--
---
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.