【发布时间】:2011-12-06 20:05:35
【问题描述】:
我遇到了一个问题,有以下问题:
带有简单动作的DefaultController:
/**
* @Route("/register")
* @Template
*/
public function indexAction() {
$oForm = $this->createForm(new RegisterType());
return array(
'form' => $oForm->createView()
);
}
在我的树枝模板中,我尝试使用:
<form action="{{ path('register') }}" method="post"></form>
但我收到以下错误:
An exception has been thrown during the rendering of a template ("Route "register" does not exist.") in EBTSCustomerBundle:Default:index.html.twig at line 2.
当我在 app/config/routing.yml 中明确定义“注册”路由时:
register:
pattern: /register
defaults: { _controller: EBTSCustomerBundle:Controller:Default:index }
然后它工作正常。找不到任何合理的文档,我认为通过注释定义的路由应该在整个应用程序中可见。
各位有什么想法吗?
【问题讨论】:
标签: php routing annotations symfony twig