CCaptcha不显示图像yii
我有一个用户注册表,在其中我试图使用Yii小部件CCaptcha显示验证码图像,但我的图像链接出现中断, 控制器文件:CCaptcha不显示图像yii,yii,captcha,Yii,Captcha,我有一个用户注册表,在其中我试图使用Yii小部件CCaptcha显示验证码图像,但我的图像链接出现中断, 控制器文件: public function actions() { return array( // captcha action renders the CAPTCHA image displayed on the contact page 'captcha'=>array( '
public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),
);
}
public function rules()
{
return array( array('verifyCode','captcha','allowEmpty'=>!CCaptcha::checkRequirements(),'on'=>'insert'),
);
}
模型文件:public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),
);
}
public function rules()
{
return array( array('verifyCode','captcha','allowEmpty'=>!CCaptcha::checkRequirements(),'on'=>'insert'),
);
}
和查看文件:<?php if(CCaptcha::checkRequirements()): ?>
<div class="row">
<?php echo $form->labelEx($model,'verifyCode'); ?>
<div>
<?php $this->widget('CCaptcha'); ?>
<?php echo $form->textField($model,'verifyCode'); ?>
</div>
<div class="hint">Please enter the letters as shown.
<br/>Letters are not case-sensitive.</div>
<?php echo $form->error($model,'verifyCode'); ?>
</div>
<?php endif; ?>
但似乎什么也没用。问题出在控制器文件上,应该是,
public function accessRules()
{
return array(
array('allow',
'actions'=>array('create', 'captcha'),
'users'=>array('*'),
),
}
而我在最后提到了验证码的操作,我发现这在Yii中是不允许的。*的所有允许操作应在一起。Yii验证码将创建png图像。断开图像链接的一个可能解释是缺少GD扩展名或imagick扩展名,这可以通过
错误中出现以下文本来识别。log
:
调用未定义的函数ImageCreateTureColor
有关详细信息和修复,请参见我测试了您的代码,没有出现错误!只是我添加了这个“on”=>“insert”,但是出现了验证码的图像!我在我的模型类中也写了'on'=>'insert'。但是那里没有运气。YIC工具生成的应用程序的验证码是可见的,这意味着,有一些东西,我丢失或写错了。