['logout', 'signup','login'] ,}" and save it."/> ['logout', 'signup','login'] ,}" and save it.">

Home  >  Article  >  PHP Framework  >  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?

藏色散人
藏色散人Original
2020-01-11 11:40:252410browse

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,
            ],
        ];
    }

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;

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;,
]) ?>

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!

Statement:
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