In Symfony2 TWIG, when trying to generate a path like this:
<a href="{{ path('folder_new', { 'folder': folder.id }) }}">
I don’t get the route I expected
Here is what I expected:
http://localhost/site/web/app_dev.php/Media/folder/new/2
here is what I in fact got from the path() command
http://localhost/site/web/app_dev.php/Media/folder/new?folder=2
Why do I get it formatted as a standard querystring (get) variable instead of a route?
The reason is that I named the variable wrong.
In my routing I had called the variable
parentand notfolder.Correct
path()should have been like this:So, I learned that when Symfony2 can’t find a route parameter matching the variable passed to the
path()function, it appends the variable in standard querystring ($__GET) format instead of generating an error message.Would have found it quicker if there were an error message, but I see the use of having it the way it is.
Cheers! =)