Hold your hat:-)
I have an SQLFORM.smartgrid with 'dog' as the main table and 'puppy' as the 
linked_table  that has a reference to the 'dog' table.
This will add an extra communal with a link 'puppy' on each dog row of the 
main table. Clicking on that link
will show a grid containing rows with only the puppies that have reference 
to the specific dog row from the main table.
So far so good. Now : The dog table has a reference to the auth_user table 
 and the grid has a constraint 
: constraints={'dog':db.dog.owner==auth.user},
This also works fine: I get only the dogs of the currently logged in user. 
Clicking on the puppy link(mentioned above) in the dog grid brings up the 
puppy grid. clicking on an Edit button on one of the puppies row
brings up the edit form for this puppy. One of the fields in the edit form 
is a drop down list with dogs so I can assign the puppy to another dog. 
*THE PROBLEM* is that the list contains ALL the dogs in the dog table 
instead of only the dogs of the current user. 

Help will be greatly appreciated

db.define_table('dog',
                Field('name'),
                Field('owner','reference auth_user',default=auth.user
                format = '%(name)s')
db.define_table('puppy',
                Field('name'),
                Field('dog', 'reference dog'),
                format = '%(name)s')

grid = SQLFORM.smartgrid(db.dog,linked_tables=['sensor'],
                        constraints={'dog':db.dog.owner==auth.user},
                        deletable=dict(puppy=False,dog=True),
                        editable=dict(puppy=True,dog=True),
                        create=dict(puppy=False,dog=True),
                        csv=False)



-- 
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.

Reply via email to