如何在sf

编程入门 行业动态 更新时间:2024-10-25 14:21:51
如何在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

更多推荐

本文发布于:2023-07-31 02:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340569.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   sf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!