Hadi Alizadeh Jalali
Hadi Alizadeh Jalali

Reputation: 300

how can i avoid pjax to submit a form twice in yii?

Is there any way to stop user to send multiple submit to server by fast clicking on submit button when using pjax in yii ?

<?php 
  Pjax::begin()
  $form = ActiveForm::begin(['options' => ['data' => ['pjax' => true]],]); 

  echo $form->field($model, 'username');
  echo $form->field($model, 'password')->passwordInput();
  echo Html::submitButton(Yii::t('app', 'Submit'), ['class' => 'btn btn-primary']);

  ActiveForm::end(); 
  Pjax::end();
?>

Upvotes: 0

Views: 894

Answers (1)

Chetan Panchal
Chetan Panchal

Reputation: 391

You need to disable the submit button after successfully submit( Without any remaining form validation error) so you can avoid multi submit at a time.

Upvotes: 2

Related Questions