get action name in yii2

To get the action name in Yii2, you can use the getAction() method from the yii\base\Controller class. Here's an example of how you can retrieve the action name:

$actionName = Yii::$app->controller->getAction()->id;

In this code snippet, Yii::$app->controller will give you the current controller object, and getAction()->id will return the name of the current action.

You can use this code in any controller or view file to get the action name dynamically.