2

好吧,在我的routing_dev.yml

_welcome:
    pattern:  /
    defaults: { _controller: AcmeDemoBundle:Welcome:index }

homepage:
    pattern:   /
    defaults: { _controller: AcmeDemoBundle:Ideup:index }

aboutme:
    pattern:   /aboutme
    defaults: { _controller: AcmeDemoBundle:Ideup:about }

_ideup:
    resource: "@AcmeDemoBundle/Controller/IdeupController.php"
    type:     annotation
    prefix:   /ideup

_form:
    resource: "@AcmeDemoBundle/Controller/FormController.php"
    type:     annotation

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_main:
    resource: routing.yml

我试图有一个简单的形式:

<form action="{{ path('_form') }}" method="POST" id="contact_form">

但我不断收到以下异常:"Route "_form" does not exist."

我只是不知道还能去哪里寻找和做什么,有什么想法吗?

4

1 回答 1

4
_form:
  resource: "@AcmeDemoBundle/Controller/FormController.php"
  type:     annotation

这只会从 FormController 加载带注释的路由。

例如:

/**
 * @Route("/my/route", name="my_route")
 */
public function myRouteAction() { ... }

如果你想要一个_form路由,你应该从 FormController 加载所有带注释的路由或以其他方式定义它:

_form:
  pattern: /path/to/your/form
  defaults: { _controller: AcmeDemoBundle:Form:myFormAction }

当然myFormAction()应该存在于FormController.

于 2012-10-10T14:42:26.643 回答