Hi Joe,

I don't know if I understood well. I think that you are trying to do a drop
list, putting in it the pet_type belonging to an owner?

In that case, in this thread:
http://groups.google.com/group/web2py/browse_thread/thread/3f2ea9bcd3a2e104/226561a9a21dc588?lnk=gst&q=drop+list#226561a9a21dc588

This need is discussed. I did something similar, and I used the code found
here:
http://www.web2pyslices.com/main/slices/take_slice/85<http://www.google.com/url?sa=D&q=http://www.web2pyslices.com/main/slices/take_slice/85&usg=AFQjCNGGFsF9ANMsi2F7idG6-zNh9kkc2g>

(thanks mr.freeze!!)

kind regards,
Bernardo

2010/11/21 Joe J <joe.jasin...@gmail.com>

> Hi All,
>  Say I have a pet table and an owner table related to each other in a
> one to many relationship (one owner has many pets).   Each owner can
> also define several pet types of their choosing.
>
> db.create_table('owner',
>    Field('name', text))
> db.create_table('pet_type',
>    Field('type_name','text'),
>    Field('type_owner',db.owner))
> db.create_table('pet',
>    Field('pet_name', 'text'),
>    Field('pet_type'), db.pet_type),
>    Field('pet_owner'), db.pet_owner))
>
> How do I create a model validator so that, when adding or editing a
> pet associated with a particular owner, only pet_types "belonging" to
> that owner show up in the form dropdown?  (Owners can define their own
> custom pet_types).
>
> This rule displays ALL defined pet_types in the pet_type table, and
> not simply the ones owned by a given owner.
> db.pet.pet_type.requires = IS_IN_DB(db, 'pet_type.id', '%
> (type_name)s')
>
> Any help is much appreciated.
> Joe

Reply via email to