0

I want different parameter names for different routes. So instead of using a fix name for the paramter like here

<a href="{{ path('page_edit', { 'param': item.value }) }}">Submit</a>

I want to do somethinig like this

<a href="{{ path('page_edit', { '{{ item.param }}': item.value }) }}">Submit</a>

But what I get as result looks like this

http://localhost/mysite/web/app_dev.php/user/edit?%7B%7B+item.param+%7D%7D=1918

How can I generate a result that looks like this?

http://localhost/mysite/web/app_dev.php/user/edit/1918
0

1 Answer 1

2

Tricky one, from the doc:

{# keys as expressions (the expression must be enclosed into parentheses) #} {% set foo = 'foo' %} { (foo): 'foo', (1 + 1): 'bar', (foo ~ 'b'): 'baz' }

https://twig.symfony.com/doc/2.x/templates.html

So in your case:

<a href="{{ path('page_edit', { (item.param): item.value }) }}">Submit</a>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.