view:
<?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 they are shown in the image above.
<br/>Letters are not case-sensitive.</div>
<?php echo $form->error($model,'verifyCode'); ?>
</div>
<?php endif; ?>
controller:siteController
public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor' => 0xFFFFFF,
'maxLength'=>'4',
'minLength'=>'2',
),
// page action renders "static" pages stored under 'protected/views/site/pages'
// They can be accessed via: index.php?r=site/page&view=FileName
'page' => array(
'class' => 'CViewAction',
),
);
}
model :LoginForm
public $username;
public $password;
public $rememberMe;
public $verifyCode;
private $_identity;
public function rules()
{
return array(
// username and password are required
//array('username, password', 'required'),
array('username','required','message'=>'用户名不能为空!'),
array('password','required','message'=>'密码不能为空!'),
// rememberMe needs to be a boolean
array('rememberMe', 'boolean'),
// password needs to be authenticated
array('password', 'authenticate'),
//verifyCode validation
array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements()),
);
}
直接访问admin.php?r=site/captcha 页面显示 “图像因其本身有错无法显示”。
请问这是咋回事??