如何在sf_method'删除'后重定向?(How to redirect after sf_method 'delete'?)
在编辑表单中使用admin-generator的后端我输出相关对象的列表,即删除
link_to ('delete', $rel_object-> name. '_delete', Array ('id' => $rel_object-> id), array ('method '=>' delete ',' confirm '=>' You are serious? ',)按删除相关对象,但被重定向到相关对象列表,我需要重定向回到对象的编辑表单。
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.
最满意答案
您的删除请求正在由控制器操作进行应答和处理 - 您需要检查路由以查看哪个。
我的executeDelete操作如下
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'); }你需要改变$this->redirect('model/index'); 成为你想要重定向的地方
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
更多推荐
发布评论