What I have done as a workaround is as follows :
def View():
if request.args(0) in ['edit']:
redirect(URL('controller', 'myEdit', args=request.args,
vars=request.vars))
if request.args(0) in ['new']:
redirect(URL('controller', 'myNew', args=request.args,
vars=request.vars))
In myEdit - I get the record to be edited from request.args(2)
Then I restrict the dropdown for specific field using :
db.tablename.fieldname.requires = IS_IN_DB(db(query), db.tablename.id,
'%(first_name)s
%(last_name)s')
For "new" I have different problem since I can't restrict the dropdown till
othe values in the form are selected (in your case, looks like you can)
So I let default values be populated, but on submit I validate and return
error.
Looking for suggestions to improve on both counts (edit/new).
-Mandar
On Monday, September 17, 2012 4:14:54 AM UTC+5:30, Michael Ellis wrote:
>
> Suppose I have an app that allows grandparents to enter, view, and edit
> information about their children and grandchildren. I want to make sure
> that each grandparent can see only his/her family's information and I want
> to use SQLFORM.grid.
>
> Using a query of the form
>
> q = (db.children.parent == db.parent.id) & \
> (db.parent.parent == db.grandparent.id) & \
> (db.grandparent.user_id == auth.user.id)
>
> form = SQLFORM.grid(q, ... )
>
> yields a results page that works as expected. The form shows only the
> grandchildren of the logged-in grandparent. However, if I click the Add or
> Edit links, the dropdown for the parent reference shows all parent ids in
> the entire parent table. How can I restrict the dropdown to show only the
> parent ids contained in the record set from the query?
>
> (Note: my actual app involves organizations, campuses, and buildings but
> the hierarchical relationships are the same as in my example. Somehow
> parent-child relationships seem easier to reason with. )
>
>
> Thanks,
> Mike
>
--