get controller action id

Hello Coders,

I have UserController with action "editagency".

And I am passing the model "UserMaster" in UserController action

and UserMaster model is of "UserMasterController"

Now in beforeSave funciton of “UserMaster” model, I want action ID of UserController(‘editagency’)

$mycontroller = Yii::import(‘application.controllers.UserController’);

$actionId = $mycontroller->action->id;

I got controller here. But I couldn’t get the action ID

Help me guys.



  1. It can be done using Yii::app()->controller->action->id

  2. Don’t access controllers and actions from inside models.


thanks for help :)