我只是想知道如何复制从 Yii 网站下载的 Yii 框架 demo-blog-contact 的确切代码到具有相同版本库的其他 yii 应用程序并且它不显示验证码。
当我转到控制器/操作页面时,它显示断开的链接而不是验证码,当我在新页面中打开断开的链接图像时,它显示另一个断开的链接。
我看到了这个CCaptcha 常见问题的链接,我检查了gd库是否已启动并正在运行,我的 函数 actions()的内容与链接所说的完全相同,并且我没有在应用程序中定义任何访问控制过滤器。
我看到了这个链接,我没有权限问题,这个链接,我没有 ajax。
我做的和这个链接说的完全一样,但没有成功。任何帮助显示这些验证码将不胜感激。
控制器 :
public function actions()
{
return array(
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),
'page'=>array(
'class'=>'CViewAction',
),
);
}
public function accessRules()
{
return array(
array('allow',
'actions'=>array('create', 'captcha'),
'users'=>array('*'),
));
}
模型 :
<?php
class ContactsM extends CFormModel {
public $name;
public $email;
public $subject;
public $body;
public $verifyCode;
/**
* Declares the validation rules.
*/
public function rules()
{
return array(
// name, email, subject and body are required
array('name, email, subject, body', 'required'),
// email has to be a valid email address
array('email', 'email'),
// verifyCode needs to be entered correctly
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
);
}
public function attributeLabels()
{
return array(
'verifyCode'=>'Verification Code',
);
}
}
看法 :
<?php $form=$this->beginWidget('CActiveForm'); ?>
<?php echo $form->errorSummary($model); ?>
<?php if(extension_loaded('gd')): ?>
<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 they are shown in the image above.
<br/>Letters are not case-sensitive.</div>
</div>
<?php endif; ?>
<div class="row submit">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
<?php $this->endWidget(); ?>