简体   繁体   中英

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();
?>

成功提交后,您需要禁用“提交”按钮(没有任何剩余的表单验证错误),这样就可以避免一次多次提交。

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