Skip to content
Advertisement

Twig get url parameter with []

I have an url like : MYURL?filter[_per_page]=25&filter[name][value]=hello

How can i get these parameters with twig ?

I’m trying {{ app.request.get('filter[_per_page]') }} but it’s always empty…

Thanks !

Edit : I’m in javascript an i want to assign this result to a javascript variable like : var param = "{{ app.request.get('filter[_per_page]') }}";

Advertisement

Answer

You must manage as an array accessing to the filter element as:

{{ app.request.get('filter')['_per_page'] }}

(This time I try before posting…)

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement