Yii20 Verification code cannot be refreshed with the Web page/Site/captcha error occurred

Source: Internet
Author: User
Tags yii
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.