-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Routes of the form /hello/{name} with an optional parameter at the end don't match as expected #5869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It matches the route "http://localhost/hello" without the extra "/" at the end |
AFAIK this case is handled in one of the routing component PRs |
@mahmouds You are correct, it does match without the trailing slash, but that doesn't match the pattern as it's defined. The pattern should be /hello/{optionalParameter}, not /hello{/optionalParameter}. If I use the generateUrl() function it does return /hello as the relative url, but that's still wrong. @mvrhov Can you please clarify PR? |
@chrismcmacken Here is the PR #5410 |
@chrismcmacken Furthermore, #5410 has nothing to do with this use case here. Your use case can be achieved by with #5424. |
@Tobion Yeah, this was a misunderstanding on my part as to the way the routing configuration works. I'm closing it as invalid, thanks for the help. It might be worth noting that in the documentation though. |
Then please open an issue on symfony-docs that mentions that handling of optional parameters should be clarified. |
Will do, I'll write it up tonight. Thanks again @Tobion |
No problem. |
I have a issue in this code: return $this->redirect($this->generateUrl('acme_hello_homepage',array('name'=>$nombre))); i have this error: |
@jesmarquez Is $nombre an object? Has to be some scalar value. |
Why are you posting this in a closed issue that was opened on documentation? |
$nombre i get using the getData() method, this is the code: $nombre = $data['task']; El Jueves 9 de enero de 2014 13:56, hacfi [email protected] escribió: @jesmarquez Is $nombre an object? Has to be some scalar value. |
@jesmarquez Looks like your task field is an entity field so you get a Task object back which you can’t use for generating the url. Try
|
Thank hacfi, $nombre is a instance! Excuse me by write a post here when is close! El Viernes 10 de enero de 2014 18:24, hacfi [email protected] escribió: @jesmarquez Looks like your task field is an entity field so you get a Task object back which you can’t use for generating the url. |
This issue can be reproduced with any brand new install of Symfony 2.1.2, just generate a default bundle and add the below route.
The route will be matched on any urls of the form http://localhost/hello/test (or other strings after hello) but the route will not be matched on urls of the form http://localhost/hello/ even though the parameter should be optional, this example is practically straight out of the Symfony2 documentation so as far as I can tell that's how it should behave.
The text was updated successfully, but these errors were encountered: