没有找到表单请求的url


Symfony - Form requested url not found

我正在做一个symfony项目。我正在与一个不会重定向到自己页面的表单作斗争。动作属性设置为",方法设置为post。在这种情况下,它应该调用相同的页面,但我在404页面结束。

下面是我的页面在动作文件中的代码:

公共函数executeDetail(sfWebRequest $request){

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();
} 

有趣的是,当我从它的url调用页面时,它会正确显示,404只在提交表单时发生。

Thanks in advance

PS: routing config is:

stories_detail:
  url:   /stories-of-the-month/:slug
  class:   sfDoctrineRoute
  param: { module: stories, action: detail}
  options: { model: Article, type: object, method: doSelectForSlug }

您需要显式地允许对路由进行POST。将路由更改为:

stories_detail:
  url:   /stories-of-the-month/:slug
  class:   sfDoctrineRoute
  param: { module: stories, action: detail}
  options: { model: Article, type: object, method: doSelectForSlug }
  requirements: 
    sf_method: [get, post]