How to properly use Yii::$app->view->params

Hi,

I must be missing something trivial but I’m unable to find out my way:

In actionIndex:




$page = Yii::$app->request->get('page');

Yii::$app->view->params['page'] = (isset($page)) ? $page : 1;



In view:




[

 'attribute' => 'myAttribute',

 'format' => 'raw',

 'value' => $this->params['page'],



View throws an undefined index ‘page’ error.

Is it not


Yii::$app->view->params['page']

supposed to be accesible anywhere like a global var?

If not, which is the proper way of doing this?

Thanks in advance,

Antonio

In GridView you can use ‘attribute’ or ‘value’, but not both at same time.

Next I’ll pass ‘page’ as params of render() method, instead use params of View.

Not using ‘value’ in GridView but in DetailView (view.php), so using both is valid.

And though using the render() approach is perfectly valid I would like to know why I’m getting this error.