Php Yii2:如何同时渲染两个视图?
我有一个带有提交按钮的表单视图,该按钮执行操作创建()功能:Php Yii2:如何同时渲染两个视图?,php,yii2,rendering,Php,Yii2,Rendering,我有一个带有提交按钮的表单视图,该按钮执行操作创建()功能: <?= Html::submitButton() ?> public function actionCreate() { $model = new Persons(); $this->render('_rpficha', [ 'model' => $model]); return $this->redirect(['index', 'id' => $model->i
<?= Html::submitButton() ?>
public function actionCreate() {
$model = new Persons();
$this->render('_rpficha', [ 'model' => $model]);
return $this->redirect(['index', 'id' => $model->id]);
}
这种客户端操作需要使用JavaScript 在view/index.php文件中:
<?php
$this->registerJs('
setTimeout(function () {
window.location.href = "http://www.google.com"
}, 5000); //5 seconds timeout. set it to 0, if you want to do it immediately',
\yii\web\View::POS_READY);
?>
浏览器中的新选项卡?您应该管理onclick for submit按钮,并使用javascript(而不是PHP)完成此操作。。正在调用所需的两个url(新选项卡中的一个)。。服务器端无法打开新选项卡。。PHP不知道客户端发生了什么。。只需渲染html代码使用renderPartial