In yii2 I am trying to pass data on link click from one page to another. And for this I am using POST as following:-
Html::a('link-name', ['/url/place-details?id='.$place_id], [
'data'=>[
'method' => 'post',
'params'=>['place'=>json_encode($place)],
]])
This is working fine when I click the link first time, the post request contains all the required data. But if I refresh the page (or go to another page and then click back from browser) this post data is lost. And following error message is displayed:-
PHP Notice – yii\base\ErrorException Undefined index: place
As the request now doesn't contain the posted data. How can I resolve this and create a request that perserve data along the sessions. I have tried passing data through sessions but same issue persists.
Following is the controller action that handles the requested URL:-
public function actionPlaceDetails($id=null)
{
$request = Yii::$app->request;
$data = $request->post('place');
$place = json_decode($data);
return $this->render('place',['place'=>$place]);
}