1. Error resolution that cannot be refreshed with the page refresh:
Modify source Code vendor/yiisoft/yii2/captcha/captchavalidator.php
/** * @inheritdoc * * Public functionclientvalidateattribute($object, $attribute, $view) {$captcha=$this->createcaptchaaction ();$code=$captcha->getverifycode (true);$hash=$captcha->generatevalidationhash ($this->casesensitive?$code: Strtolower ($code));$options= [' Hash '=$hash,' HashKey '=' yiicaptcha/'.$captcha->getuniqueid (),' CaseSensitive '=$this->casesensitive,' message '= Yii::$app->geti18n ()->format ($this->message, [' attribute '=$object->getattributelabel ($attribute),], Yii::$app->language),];if($this->skiponempty) {$options[' Skiponempty '] =1; } validationasset::register ($view);return' Yii.validation.captcha (value, messages, '. Json_encode ($options, Json_unescaped_slashes | Json_unescaped_unicode).');'; }}
$code=$captcha->getVerifyCode(falsefalse改成true
In addition appears
Workaround:
To modify the value of captchaaction in model
['verifyCode''captcha','message' =>'验证码错误','captchaAction'=>'login/captcha'],
In view:
= $form->field($loginForm, 'verifyCode',['options'=>['class' => 'form-group']])->widget(Captcha::className(),[ 'captchaAction' => '/login/captcha', 'imageOptions' => ['alt'=>'点击换图','title'=>'点击换图','style'=>'cursor:pointer'], 'options' => [ 'placeholder' => '验证码', 'class' => 'form-control', 'style' => 'margin-top:10px;' ] ])->label(false); ?>
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the Yii20 verification code can not be refreshed with the webpage Site/captcha errors, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.