The id is in form.vars.id

On Feb 20, 6:18 am, selecta <[email protected]> wrote:
> ah thanks, but could I ask for one addition
> how do I redirect to a record just created with crud?
>
> crud.create(db_method, onaccept =
> redirect_parent(URL(request.application, 'plugin_restapidoc',
> 'edit_method', args=[???])
>
> On Feb 19, 1:39 pm, mdipierro <[email protected]> wrote:
>
> > def redirect_parent(url):
> >     def tmp(form):
> >         response.headers['web2py-component-
> > command']="document.location='%s'" % url
> >         raise HTTP(200)
> >     return tmp
>
> > def edit_method():
> >     if not request.args:
> >         return dict(form = crud.create(db_method), method = None)
> >     method = db(db_method.id == int(request.args(0))).select().first()
> >     form = crud.update(db_method,
> > method,onaccept=redirect_parent(URL(.....))  #<<<<<
> >     return dict(form = form, method = method)
>
> > On Feb 19, 4:53 am, selecta <[email protected]> wrote:
>
> > > how can I tell crud to redirect to an url that displays the created
> > > item (of course only on successful creations)
>
> > > my controller looks like that
>
> > > def edit_method():
> > >     if not request.args:
> > >         return dict(form = crud.create(db_method), method = None)
> > > #something with next/onvalidate/... here?
> > >     method = db(db_method.id == int(request.args(0))).select().first()
> > >     form = crud.update(db_method, method)
> > >     return dict(form = form, method = method)
>
> > > in the view i use LOAD and method to get some other stuff

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to