Forward data from one controller action to other in Yii2

14,293

In Yii 2, you can use this which yields the same result of forward():

Yii::$app->runAction('new_controller/new_action', ['param1'=>'value1', 'param2'=>'value2']);
Share:
14,293

Related videos on Youtube

alwaysLearn
Author by

alwaysLearn

Updated on September 16, 2022

Comments

  • alwaysLearn
    alwaysLearn over 1 year

    Is it possible to forward data from one controller action to other before the render? Basically, I want to now if we have something that Zend _forward does?

    Here is my scenario. I have a payment gateway that returns data back to my controller action, what I want is to handle data on separate controller/action but render the home page (without redirection). Is it possible to forward control from one controller/action to other ?

    Can anybody suggest me can I go for ?

  • Ruben
    Ruben about 8 years
    if you want to render this in a modal, add $this->layout = false; to your controller action
  • Skatox
    Skatox over 7 years
    He asked for the Yii2 version