As default, error message coming on keyup
and after pressing
submit button in form (If any error exist for that particular attribute). Which Is Ok. Working perfectly fine.
But, Is it possible to disable
error message on key up
? Means, error message, if any, should come only on pressing submit button.
View
<?php $form = ActiveForm::begin([ 'id' => 'register-form']); ?>
<?= $form->field($model, 'first_name',['inputOptions' => ['class' => 'form-control fname','placeholder'=>'First Name']])->label(false); ?>
.
.
<p><?= Html::submitButton('REGISTER', ['name' => 'register-button']) ?></p>
Controller
public function actionRegister()
{
$model = new Users(); // User Model
if ($model->load(Yii::$app->request->post())) {
// For Ajax Email Exist Validation
if(Yii::$app->request->isAjax ) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
.
.
}
}
I found How to disable client side validation messages of active form in Yii 2?.
$form = ActiveForm::begin(['fieldConfig' => ['template' => '{label}{input}']]);
But, In this answer. Error message neither coming on key up nor on pressing submit button. To show error summary, I need to use <?= $form->errorSummary($model) ?>
. So, Is there any way to disable key up
error message and show error message as it was showing before only on pressing
submit button.