I believe you just set this through the "requires" property of the field:
db.table2.table1_name.requires(IS_IN_DB(db, 'table1.name',
db.table1._format))
That prevents entering any values in table1_name that aren't in
table1.name. I believe you can also set unique=True on table2.table1_name
(just as you have on table1.name). Then the values will be unique within
table2.table1_name and will also be drawn from table1.name.
On Wednesday, June 25, 2014 11:17:17 AM UTC-4, KRG KCIHTRAK wrote:
>
> I have two tables like below.
> Table1 (Field(name), unique = True)
> Table2 (Field(table1_name, 'reference Table1',
> Field(name))
>
> I want to make the Table2's name field as unique based on the value in
> table1_name.
>
> how can I do it with web2py?
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.