我在yii2中有以下代碼,但驗證碼圖像不顯示!
控制器:
yii2 captcha圖像不顯示
public function actions() {
return [
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
'foreColor' => 0xF9AF21,
'maxLength' => 5,
'minLength' => 3,
'padding' => 5,
'offset' => 1,
'transparent' => true,
'height' => 40
],
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
模型:(規則)
['verifyCode', 'captcha',],
視圖:
$form->field($model, 'verifyCode')->widget(Captcha::className()])
好的!這真是很好的解釋。 –