【发布时间】:2017-11-29 12:16:05
【问题描述】:
我正在为登录页面使用引导模式。如果我在弹出窗口中提交表单将被关闭并显示响应。但不是关闭弹出窗口,而是想在同一个弹出窗口中显示响应。任何人都可以在不关闭弹出窗口以显示响应数据的情况下帮助我。
示例查看页面:
<?php Pjax::begin(); ?>
<?= Html::beginForm(['site/login'], 'post'); ?>
<?= Html::input('text', 'email', ['class' => 'form-control']) ?>
<?= Html::input('text', 'password', ['class' => 'form-control']) ?>
<?= Html::submitButton('Login', ['class' => 'btn btn-lg btn-primary', 'name' => 'login']) ?>
<?= Html::endForm() ?>
在控制器中
if ($model->load(\Yii::$app->request->post())) {
$authenticateUser = $model->login();
if($authenticateUser == "Locked"){
Yii::$app->session->setFlash('invalid', 'Your account has been locked. Please contact customer service for assistance');
return $this->redirect('index');
}else{
Yii::$app->session->setFlash('success', 'Successfully logged in');
return $this->redirect('index');
}
}
在控制器中,我也尝试使用 renderAjax 而不是 redirect 。但它没有按预期工作。
【问题讨论】:
标签: php jquery twitter-bootstrap yii2 yii2-advanced-app