I think you mean

db.companyactivity.company.requires=[IS_IN_DB(db,db.company.id,'%
(companyname)s'),IS_NOT_IN_DB(db
(db.companyactivity.activity==request.vars.activity),db.companyactivity.company,error_message='already
in database')]


On Dec 8, 8:14 am, annet <annet.verm...@gmail.com> wrote:
> In my model I defined the following table:
>
> db.define_table('companyactivity',
>     Field
> ('company',db.company,default='',notnull=True,ondelete='CASCADE',
> writable=False, readable=False),
>     Field
> ('activity',db.activity,default='',notnull=True,ondelete='RESTRICT'),
>     migrate=False)
>
> db.companyactivity.company.requires=[IS_IN_DB(db,db.company.id,'%
> (companyname)s'),IS_NOT_IN_DB(db
> (db.companyactivity.activity==request.vars.activity),db.companyactivity.activity,error_message='already
> in database')]
>
> When I insert records using appadmin, the validator works, I cannot
> insert the same combination of company.id and activity.id twice.
>
> However, when I insert records using:
>
> form=crud.create(db.companyactivity)
>
> ... the validator doesn't work, I can insert the same combination of
> company.id and activity.id more than once.
> Did I miss anything in the implementation?
>
> 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 web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to