Home > PHP Framework > YII > What should I do if the yii verification code does not display pictures?

What should I do if the yii verification code does not display pictures?

藏色散人
Release: 2020-01-11 11:40:25
Original
2430 people have browsed it

What should I do if the yii verification code does not display pictures?

#yii What should I do if the verification code does not display the picture?

Use of verification code in yii2 - the picture is not displayed

Recommended learning: yii framework

1. In the controller

public function actions()
    {
        return [
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
            ],
        ];
    }
Copy after login

2. There must be a verification code field in the model $verifyCode

3. In the view,

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\captcha\Captcha;
Copy after login

automatically generates a form

Verification code code in the page

<?= $form->field($model, &#39;verifyCode&#39;)->widget(Captcha::className(), [
                    &#39;template&#39; => &#39;<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>&#39;,
]) ?>
Copy after login

Permissions in the controller may cause the verification code image not to be displayed,

public function behaviors()

{

                                                                                                                                                                                                                                                       'access' => 'only' => ['logout', 'signup','login'],

                'rules' => Actions' = & gt; ['signup'],

# 'all' = & gt; true,

'roles' = & gt; ['? '],

##] , [

'Actions' = & GT; ['Logout'],

'Alow' = & GT; TRUE,

## 'ROLES' = > ['@'],

                                                                                                                                                                                                                        #                                                                                                                                                                                                                                                                                                          #                                                                                                                                                                                                                                                                                                        .

The above is the detailed content of What should I do if the yii verification code does not display pictures?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
yii
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template