How to mix POST and GET parameters in one link

Hi All,

I could not find this question on the forum. I’d like to pass GET and POST parameters with single link. The reason I’d like to do it is to maintain good looking urls with not too many GET parameters.

I’m passing now just one GET parameter which is used in the URL rules. On top of that I’d like to pass 3 more POST parameters which could be intercepted and used on the landing page. Is it feasible with Yii2 ? Thanks in advance

Regards

lukBB

It’s not about Yii. Html in general doesn’t allow you to pass POST parameters in a standard link (a href…). You either have to post a form or do a bit of work with JS/jQuery.

Thanks Patrick will look for another solution

As said, POST information is done via a form. However the action property of the activeForm component looks like it can have a GET parameter.

I just looked at some of the Gii generated CRUD. Click on an edit button in the GridView, then looked at the source returned in the browser.


<form id="w0" action="/index.php?r=announcement%2Fupdate&amp;id=1" method="post">

You may also be able to use AJAX ‘post’ with a GET tagged url.

1 Like

Just after post the above, I noticed that Yii uses GET information in a POSTed form.


?r=controller/action

Isn’t ‘r’ a GET value? :o

1 Like