Abylay
Abylay

Reputation: 220

How to get params in action passed via runAction in Yii2

I used runAction() function to launch action within another action in the same controller. Yii::$app->runAction('main/goods', ['model_id' => $goods->id]);. How to get this variable in actionGoods()?

Upvotes: 10

Views: 10129

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

Try this way

Yii::$app->runAction('main/goods', ['model_id' => $goods->id]);

In MainController

public function actionGoods($model_id)
{
    ..... yuor code
}

Upvotes: 16

Related Questions