.
enableAjaxValidation , .
<?php $form = ActiveForm::begin([
'id' => 'some-id',
'enableAjaxValidation' => true,
'enableClientValidation' => false,
]); ?>
, , . enableAjaxValidation . - Captcha false.
, AJAX, , , . , , AJAX , .
<?= $form->field($model, 'username', ['enableAjaxValidation' => true]) ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'verifyCode')->widget(Captcha::className()) ?>
, AJAX , , , .
:
, @AnHuy answer.
captcha (SiteController Yii2) actions.
public function actions() {
return [
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
yii\captcha\CaptchaAction , Yii, app\models\captcha\CaptchaAction.
public function actions() {
return [
'captcha' => [
'class' => 'app\models\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
, models/captcha/CaptchaAction.php.
<?php
namespace app\models\captcha;
use Yii;
use yii\captcha\CaptchaAction as CaptchaActionBase;
class CaptchaAction extends CaptchaActionBase {
public function validate($input, $caseSensitive) {
if (Yii::$app->request->isAjax) {
return true;
}
return parent::validate($input, $caseSensitive);
}
}
, AJAX, true , . , .