2017-11-29 19 views
0

로그인 페이지에 부트 스트랩 모달을 사용하고 있습니다. 내가 팝업에 양식을 제출하면 폐쇄되고 응답이 표시됩니다. 그러나 팝업을 닫는 대신 동일한 팝업 창에 응답을 표시하려고합니다. 누군가 응답 데이터를 표시하기 위해 팝업을 닫지 않고 나를 도울 수 있습니까?Yii2 bootstrap 모달 팝업을 닫지 않고 양식을 제출하는 방법 pjax를 사용하는 방법

샘플보기 페이지 :

<?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으로 시도했습니다. 그러나 예상대로 작동하지 않습니다.

답변

0

직접 자바 스크립트 처리기 beforeSubmit을 추가하여 아약스를 통해 양식을 제출해야합니다. this link을 참조하십시오.

0

봅니다 아래 하나

use yii\widgets\Pjax; 
use yii\bootstrap\ActiveForm; 

<?php Pjax::begin(); ?> 
    <?php 
     $form = ActiveForm::begin([ 
     'id' => 'form-id',     
     'options' => ['class' => 'form-horizontal','data-pjax' => true], 
     ]); 
    ?> 
     // Your fields 
    <?php ActiveForm::end(); ?> 
<?php Pjax::end(); ?>