在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/PHP/ php yii 驗證碼問題

php yii 驗證碼問題

conroller 里面:

use yii\captcha\Captcha;

public function actions()
{
    return [
        'captcha' => [
            'class' => 'yii\captcha\CaptchaAction',
            'maxLength' => 5,
            'minLength' => 5
        ],
    ];
}

model 里面:

public $verifyCode; 
public function rules()
{
    return [
        [
            'verifyCode',
             'captcha',
        ],
    ];
}
public function attributeLabels()
{
    return [
        'verifyCode' => '', 
    ];
}    

表單里面:

use yii\captcha\Captcha;
<?php 
    echo Captcha::widget([
        'name'=>'captchaimg',
        'captchaAction'=>'login/captcha',
        'imageOptions'=>[
            'id'=>'captchaimg', 
            'title'=>'換一個', 
            'alt'=>'換一個',
            'style'=>'cursor:pointer;margin-left:25px;'
            ],
        'template'=>'{image}'
        ]);
?>

視圖結(jié)果不顯示驗證:

clipboard.png

html 代碼:

clipboard.png
為什么不顯示呢?沒有報錯。

回答
編輯回答
旖襯

你那個src怎么有個v1

2017年10月22日 04:45
編輯回答
柒槿年

具體報錯是看src里的那個url.

2017年3月26日 04:40
編輯回答
萌二代

視圖可以這樣:

src="<?=yii::$app->urlManager->createUrl('login/captcha')?>"
onclick= "this.src='<?=yii::$app->urlManager->createUrl('login/captcha')?>&d='+Math.random();"
2017年11月8日 16:31