You can test if the record was deleted by checking for the 
"delete_this_record" variable:

if form.vars.delete_this_record:

Also, instead of handling the logic after form.accepts(), you could use 
form.process(..., onsuccess=some_function) and have the some_function() 
callback check for the delete and do the redirect.

Anthony

On Friday, February 17, 2012 12:43:37 PM UTC-5, Richard wrote:
>
> Hello, 
>
> When user submit, I redirect him on a read form, but I get in trouble 
> when for example user has delete a record with update form. 
>
> I solve it like this when use SQLFORM() : 
>
>         if form.accepts(request.vars, session): 
>             session.flash = T('form accepted') 
>             if len(db(db.table1.id == 
> form.vars.id).select(db.table1.id)) == 1: 
>                 redirect(URL(r=request, 
> f='read',args=(request.args(0),form.vars.id))) 
>             else: 
>                 redirect(URL(r=request, 
> f='select',args=(request.args(0)))) 
>
> But I notice that CRUD has delete_next= option... Could it be add to 
> SQLFORM somehow? Book seems to be silent on this scenario... Should I 
> use form.accept().accepted. It has a next methode, but I don't think 
> it allows to manage conditional redirection... 
>
> Thanks 
>
> Richard

Reply via email to