Is it possible to pass a GET parameter to the controller's action when clicking on a link?

Controller Code:

 public function actionFilter() { $categoryId = Yii::$app->request->get('id'); return $this->render('index', compact('categoryId')); } 

The link in the template itself:

 <?= Html::a('Horror', ['site/filter'], [ 'data' => [ 'method' => 'get', 'params' => [ 'id' => 'horror', ], ] ]); ?> 

action controller's action is not even called, but with a POST request, everything works correctly.

  • And what does the link look like in html? And what request goes to the server when you click? - cronfy
  • The link looks like this: / a> - Fedor Filippov

1 answer 1

This is how it worked: <?= Html::a('Horror', ['site/filter', 'id'=>'horror']); ?> <?= Html::a('Horror', ['site/filter', 'id'=>'horror']); ?>