Your requries says....

company must be in company.id and company cannot be in company.id

Your custom error message is probably throwing you off, since company does
not exist in company.id, it throws an error.

You want..

db.paymentdata.company.requires = [IS_IN_DB(db, 'company.id',
'%(companyname)s'), IS_NOT_IN_DB(db, 'paymentdata.company')]

which says

company must be in company.id and company cannot be in paymentdata.company

-Thadeus




On Fri, Dec 18, 2009 at 3:27 AM, annet <[email protected]> wrote:

> I defined the following table:
>
> db.define_table('paymentdata',
>    Field
>
> ('company',db.company,default='',notnull=True,ondelete='CASCADE',unique=True),
>    Field('account',length=10,default='',notnull=True),
>    Field('BIC',length=8,default='',notnull=True),
>    Field('IBAN',length=34,default='',notnull=True),
>    Field('VAT',length=24,default='',notnull=True),
>    Field('created_on',type='datetime',writable=False,readable=False),
>    Field
> ('modified_on',type='datetime',writable=False,readable=False),
>    migrate='paymentdata.table')
>
> db.paymentdata.company.requires=[IS_IN_DB(db,db.company.id,'%
> (companyname)s'),IS_NOT_IN_DB(db,'company.id',error_message=T
> ('paymentdata already in database'))]
>
>
> The user shouldn't be able to enter paymentdata more than once, I
> thought by making company unique and defining the validator I would
> implement that constraint. However, even when inserting a record in an
> empty paymentdata table I get the error message ' paymentdata already
> in database'. Why?
>
>
> Kind regards,
>
> Annet
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<web2py%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/web2py?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" 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.


Reply via email to