Reputation: 361
I have a route:
professor_identity_edit:
path: /professor/{id}/identity
defaults: { _controller: FrontBundle:ProfessorIdentity:edit }
How can I get the parameter {id}
in twig.html
file ?
I already tried app.request.query.get('id')
but with no success.
Upvotes: 2
Views: 7223
Reputation: 12730
Not a good thing but you can still do. Normally you would pass the info to Twig from the controller like @Maerlyn pointed out.
Get route parameters in Twig.
{{ app.request.attributes.get('_route_params') }}
AND
Gets whole bundle name in Twig.
{{ app.request.attributes.get("_controller") }}
Get route name in Twig.
{{ app.request.attributes.get('_route') }}
Upvotes: 4
Reputation: 361
I found the solution:
{{ app.request.attributes.get('_route_params')['id'] }}
Upvotes: 1