E
E
enigma20302021-09-22 13:24:43
symfony
enigma2030, 2021-09-22 13:24:43

How to change url output format?

Good afternoon.

If you use the path('_URL'_, { filter: { type: '_TYPE_' } }) function, then an address of the form _URL_?filter%5Btype%5D=_TYPE_ is generated.

The address must be of the form _URL_?filter[type]=_TYPE_

For this you can use path('_URL'_, { filter: { type: '_TYPE_' } })|replace({'%5B': '[', '%5D': ']'}) and it will work as expected.

How to do the same for forms? Because there, the address bar is formed according to the first pattern.

For example, there is a form

<form action="_URL_">
<input type="text" name="filter[type]" value="_TYPE_" />
<button>Apply</button>
</form>


If you click on "Apply" then a link like _URL_?filter%5Btype%5D=_TYPE_ will be generated

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sl0, 2021-09-22
@sl0

1. I would not be perverted with but would write my own version of path so that the code is cleaner. 2. Changing the path for forms is quite simple . |replace({'%5B': '[', '%5D': ']'}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question