1

controller:

public function actions() {
    return [
        'error' => [
            'class' => 'yii\web\ErrorAction',
        ],
        'captcha' => [
            'class' => 'app\captcha\CaptchaAction',
            'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
        ],
    ];
}

views

<div>
            <?php
            echo Captcha::widget([
                'name' => 'captcha',
                'imageOptions' => [
                    'id' => 'my-captcha-image'
                ]
            ]);
            ?>
            <button id="refresh-captcha">Refresh</button>
        </div>
        <script>
                $('#refresh-captcha').on('click', function(e){
                    e.preventDefault();
                    $('#my-captcha-image').yiiCaptcha({"refreshUrl": "../site/captcha?refresh=1"});
                    $('#my-captcha-image').yiiCaptcha('refresh');
                })
            </script>
        <?php } ?>

I tried to make a new controller, and so on, but nothing happened, I can’t find a way out for this, what can I do?

0 Answers0