D
D
Doniyor Mamatkulov2018-10-23 09:49:29
Yii
Doniyor Mamatkulov, 2018-10-23 09:49:29

How to prevent form auto submit?

Hello,
If I fill out my authorization form (login / password) and do not click on the submit button, the form is still submitted.
view:

<?php
$form = ActiveForm::begin([
  'id' => 'login-form',
  'enableAjaxValidation' => true,
  'action' => ['user/login']
]);
?>
<?= $form->field($loginModel, 'phone')->textInput(['placeholder'=>'Номер телефона', 'autocomplete'=>'off'])->label(false) ?>
<?= $form->field($loginModel, 'password')->passwordInput(['placeholder'=>'Ваш пароль', 'autocomplete'=>'off'])->label(false) ?>
<?= Html::submitButton(Yii::t('app', 'Sign in'), ['class' => 'btn btn-brand btn-block']) ?>
<?php ActiveForm::end() ?>

How to prevent form from auto submit and make it submit only on button click?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antony Tkachenko, 2018-10-23
@LemonFox

enableAjaxValidation - validation is started via ajax. Either turn it off or make a separate validation route.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question