Karmazzin
Karmazzin

Reputation: 531

How to redirect after sf_method 'delete'?

Backend with admin-generator in edit form I output the list of related objects, which is to remove the

link_to ('delete', $rel_object-> name. '_delete', 
           Array ('id' => $rel_object-> id), 
          array ('method '=>' delete ',' confirm '=>' You are serious? ',)

press to delete the related object, but is redirected to a list of related objects, and I need to do a redirect back to the edit form of the object.

Upvotes: 3

Views: 228

Answers (1)

Manse
Manse

Reputation: 38147

Your delete request is being answered and dealt with by a controller action - you need to check your routing to see which.

My executeDelete action is as follows

public function executeDelete(sfWebRequest $request)
{
    // delete the associated object
    $request->checkCSRFProtection();
    $this->forward404Unless($model= Doctrine_Core::getTable('model')->find(array($request->getParameter('id'))), sprintf('Object does not exist (%s).', $request->getParameter('id')));
    $model->delete();

    // change this line
    $this->redirect('model/index');
}

You need to change $this->redirect('model/index'); to be wherever you want to redirect to

Upvotes: 2

Related Questions