-1

I want to pass three parameter to a PHP file with twig path(). I found a solution in this question. It works fine with one value, but with two values it puts & instead of & in the URL. this is the code I used:

var route = "{{ path('dashboardTable', { 'data1': 'fistData', 'data2' : 'secondData})}}";
route = route.replace('firstData',  D1);
route = route.replace('secondData',  D2 );
window.location.href = route;

It sets the firstData and socondData and the URL will be this:

http://localhost:8000/dashboard/table?data1=Low&data2=deactive

but because of the & it's not working. how can I change & to & ?

the funny point is that if I put the amp; before data2 in my get request like below, it works fine!

$data2 = $_GET["amp;data2];
4

1 Answer 1

0

According to DaveCoast comment I added raw in the code like below and it solved the problem .

var route = "{{ path('dashboardTable', { 'data1': 'fistData', 'data2' : 'secondData})|raw}}";
route = route.replace('firstData',  D1);
route = route.replace('secondData',  D2 );
window.location.href = route;
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.