asuarez
asuarez

Reputation: 3

Path function is not working as expected in twig template

I have this route on symfony2:

flight_admin_news_form:
 pattern:  /news/{action}/{id}
 defaults: { _controller: FlightAdminBundle:News:form,action:create,id:0 }
 requirements:
        action: create|edit
        _method: GET

When I use it like this on my base template:

<a href="{{ path("flight_admin_news_form", {"action": "create"}) }}">Add new</a>

I expect to get an URL like this: /news/create but instead I get this: /news/

When I use it inside a child template it works...

Am I missing something?

Thanks in advance

Upvotes: 0

Views: 418

Answers (1)

Maerlyn
Maerlyn

Reputation: 34125

Symfony will generate the shortest route possible. Since "create" is your default action, it generates only /news/, because it's identical to /news/create.

Upvotes: 1

Related Questions