It is related to the link which on clicking lands on this action it could either be
inside your GridView
, /your_project_root/views/post/index.php
file from where you are clicking to view the post detail by submitting the id.
Or a normal link in your view somewhere
1) For GridView go to your action column and change the ['class' => 'yii\grid\ActionColumn']
to the following
[ 'class' => 'yii\grid\ActionColumn' ,
'header' => 'Actions' ,
'template'=>'{view}{update}{delete}',
'buttons'=>[
'view'=>function($url,$model){
$html = '<span class="glyphicon glyphicon-search"></span>';
return Html::a($html,["post/view",'post'=>$model->id]);
}
],
] ,
and change the actionView($id)
in your PostController
to the actionView($post)
and replace all occourences of the $id
with $post
inside the action code.
2) if it is a normal link then you have to just change the url
for that link like below
Html::a($html,["post/view",'post'=>$model->id]);
where $model
should be replaced by the appropriate variable.