1
我正在开发一个symfony项目。我正在与一个不会重定向到自己的页面的表单战斗。 action属性设置为“”并且方法设置为发布。在这种情况下,它应该调用相同的页面,但我在404页面结束。Symfony - 表单请求的网址找不到
这里是我的网页在操作文件中的代码:
公共职能executeDetail(sfWebRequest $要求) {
if($request->isMethod(sfRequest::POST))
{
if(!$this->getUser()->isAuthenticated())
$this->redirect('@user_login');
$formData = $request->getParameter($this->form->getName());
$this->form->bind($formData, $request->getFiles($this->form->getName()));
if ($this->form->isValid())
{
$user = $this->getUser()->getLogged();
$comment = $this->form->save();
$comment->setIsActive(1);
$comment->setAuthor($user);
$comment->setHash(md5(uniqid(rand(), true)));
$comment->setArticle($this->detail);
$comment->save();
$this->status = 'SUCCESS';
}
else
{
$this->status = 'ERROR';
}
}
$this->story = $this->getRoute()->getObject();
$this->status = false;
$this->bAuthorLogged = false;
$this->form = new ArticleCommentForm();
}
有趣的是,当我调用页面从它的网址是正确显示,404仅在使用表单提交时才会发生。
在此先感谢
PS:路由配置是:
stories_detail:
url: /stories-of-the-month/:slug
class: sfDoctrineRoute
param: { module: stories, action: detail}
options: { model: Article, type: object, method: doSelectForSlug }
您可以发布您的路由配置吗? – MrGlass 2012-01-02 22:29:04
谢谢你的帮助。我编辑了帖子,你可以在那里找到它。 – 2012-01-02 23:07:09
您确定在您的表单中url操作是否正确创建? – macgyver 2012-01-03 00:10:51