I have in twig template an anchor tag :
<a href="{{ path('park_resort_calculator', {'price': ad.price }) }}"><button id="redirect_calculator">Calculator</button></a>
How can I take the value of ad.price in the template park_resort_calculator
?
Thank you!
you can get the query string parameters in a template using
{{ app.request.get('price') }}
Some reference of the app shortcut here in the docs Hope this help
if i understand your question correctly, in your controller uou need something like this:
/**
* @Route("/calculate/{price}", name="park_resort_calculator")
*/
public function calculateAction($price)
{
echo $price;
// ...
}
Oh... you shouldn't nest a <button>
inside an <a>
tag.... it may cause issues.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.