Captcha in the backend not showing

Hello I’m trying to put a captcha on the backend login and everything works except the captcha is not showing. On the frontend everything works like a charm. I didn’t enable pretty URL yet, but that works as well because I tested it. Hiding the index.php on the other hand is also not working in the latest yii2 version, enabling hiding index.php gives also routing errors. Did somebody fix the ‘captcha-backend’ issue??

Can somebody confirm if this is a bug?? Did somebody succeed of implementing a captcha for the backend??

After I reached my milestone in my yii2 project I was left with the captcha issue so I used the following workaround. I didn’t invest much time in the captcha code of Yii2 but I think there is a routing issue, a bug. Anyway this is the workaround

In the backend/site/login.php

I replaced:


    $form->field($model, 'verifyCode')->widget(Captcha::className(), [

    'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',]) 




    $tag = $form->field($model, 'verifyCode')->widget(Captcha::className(), [

                'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',]); 

    $tag = preg_replace('/backend/', 'frontend', $tag); 

    echo $tag;


nice job

i used ur solution but cant refresh the captcha by clicking it

how can i do that?