Reputation: 224
Can i get data that i got from controller, and then send it to another controller (in the same folder) in Yii2?
this is my SiteController:
public function actionIndex()
{
...
$data = Yii::$app->request->post();
$reg_res = $data['ColoringForm']['region'];
...
i want to send $reg_res to my DataController:
public function actionShowdata()
{
$reg_res ??
how can i do this?
Upvotes: 0
Views: 3138
Reputation: 410
You can use the following to run a separate action within the same request:
Yii::$app->runAction('controller/show-data', ['param1'=>'value1', 'param2'=>'value2']);
Upvotes: 0
Reputation: 771
Post array data is not possible to send from on controller to another controller but you can send it through parameters.
Try below code
$this->redirect(array('controller/action', 'param1'=>'value1', 'param2'=>'value2',...)
Upvotes: 1