When users are accessing a table, grandfather controller passes args to
parent controller.
Parent controller then passes args to child controller so user can edit
child table records.
Now after editing child record, user wants to return from child record to
parent record and parent controller.
What is syntax for child controller remembering what records parent
controller was looking at?
GRANDPARENT controller that calls the parent controller
dict(header='Comments', body=lambda row: A('Comments',_class="btn btn-mini"
, _href=URL('comment_on_an_object', vars=dict(filter=row.objectID, id=row.id
)))),
PARENT CONTROLLER - child is called in parent html below this
def comment_on_an_object():
is_owner = (lambda row: row.created_by == auth.user_id) if auth.user
else False
db.SuperObjectComment.superObjectID.default = request.get_vars.filter
db.SuperObjectComment.superObjectID.readable = False
db.SuperObjectComment.superObjectID.writable = False
commentsHeader=db.SuperObject(request.get_vars.filter)
form = crud.create(db.SuperObjectComment)
objectComments = db(db.SuperObjectComment.superObjectID ==
request.get_vars.filter).select()
return locals()
PARENT HTML that calls the child controller
<td> {{if auth.user_id == objectComment.created_by:}} {{=A("Edit me",
_href=URL('default','edit_object_comment', args=objectComment.id),
_class='btn btn-min')}}</td>
CHILD CONTROLLER - edit_object_comment
def edit_object_comment():
db.SuperObjectComment.superObjectID.readable = True
db.SuperObjectComment.superObjectID.writable = False
comment_id = request.args(0) or redirect(URL('view_suggestions'))
form = SQLFORM(db.SuperObjectComment, comment_id, next=(URL('default',
'comment_on_an_object'<!--this return to parent doesn't even get called.
Why? -->)), _class='formstyle')
if form.process().accepted:
response.flash = 'form accepted'
redirect(URL('comment_on_an_object', vars=dict(filter=???, id=???
<!--what
do I put here? It returns to parent but args are all wrong -->)))
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)
thanks,
Alex Glaros
--
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.