Reputation: 1895
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
.
Upvotes: 2
Views: 366
Reputation: 1364
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()
Upvotes: 0
Reputation: 133370
You can use redirect
return $this->redirect('/your-controller/your-actionindex',302);
or simply without return
$this->redirect('/user/index',302);
Upvotes: 2