Reputation: 1035
I have page A with link :
<a href="/b?id=1"></a>
with controller BController.php
like:
...
public function actionB(){
$id = Yii::$app->request->getQueryParam("id");
$model= new TestModel();
$data = $model->find()->where(["id" => $id])->one();
return $this->render('b',["data"=>$data]);
}
when link in A
click , it redirect to views b
views b.php
just display value:
<?= $data->field_name?>
Now I can not see anything in views ,sure that in controller ,I can get data success
Please help me what wrong
Upvotes: 1
Views: 44
Reputation: 133400
If you want pass id to actionB you should use
public function actionB($id){
//$id = Yii::$app->request->getQueryParam("id");
$model= new TestModel();
$data = $model->find()->where(["id" => $id])->one();
return $this->render('b',["data"=>$data]);
}
Upvotes: 1