Reputation: 31
I have the following route in php
$collection->add('verify', new Route('/verify/{confirmation}', array(
'_controller' => 'AppBundle:Verify:verify',
)));
And I want to generate a url with the confirmation parameter
$url = $this->generateUrl('verify', array('confirmation' => $user-> getConfirmation()));
and show it on a twig template
a href="{{ url('url') }}"
but I'm getting this error
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "url" as such route does not exist.") in Emails/registration.html.twig at line 5. 500 Internal Server Error - Twig_Error_Runtime 1 linked Exception: RouteNotFoundException »
what am I doing wrong?
Upvotes: 0
Views: 242
Reputation: 9585
In you twig template change a href="{{ url('url') }}"
to:
a href="{{ url('verify', {'confirmation': app.user.confirmation}) }}"
or {'confirmation': confirmation}
and make sure to pass confirmation
variable to template from controller.
Upvotes: 2