2

How get any controller->id from current controller,like if I in the default site controller and I write Yii::$app->controller->id/index it gives me the site/index,but if I have another controller like named student(and I am in the site controller) how can I redirected to student/index.

Muhammad Younus
  • 1,896
  • 19
  • 20

2 Answers2

2

You can use redirect

 return $this->redirect('/your-controller/your-actionindex',302);

or simply without return

$this->redirect('/user/index',302);
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
0

Controller Id :

$this->id

Here $this refers to controller.

And For getting action id :

$this->action->id

If you are using out of controller then

Yii::app()->controller->id

or

Yii::app()->getController()->getId()
Bhavin Solanki
  • 1,364
  • 11
  • 27