简体   繁体   中英

How to Redirect from one view to another view with data - Yii2

i want to pass 1 variables from a view to another view with post method. use this redirect code but its not working

 Yii::$app->getResponse()->redirect('home','id'=>$id)->send();

尝试这个

Yii::$app->getResponse()->redirect(['home','id' => $id])->send();

For the sake of completeness in a controller context you may use:

class MyController extends \yii\web\Controller
{
    public function actionIndex()
    {
        return $this->redirect(['home', 'id' => 123]);
    }
}

Where the array parameter of redirect() is equal to yii\\helpers\\Url::to() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM