captche文件下:两个类在内部有结合
CCaptcha.php #form表单使用 $this -> widget('CCaptcha'); 会间接调用控制器的方法,路由:user/captcha
CCaptchaActive.pp #控制器使用 生成验证码的核心类(有更新文件)
//验证码控制器,被actions访问的类都要继承CActive
function actions(){
return array(
'captcha'=>array(
//此class = http://www.yii.com/index.php?r=user/captcha/ 可以看到验证码
'class'=>'system.web.widgets.captcha.CCaptchaAction', //有更新文件(=framework/web/widgets/captcha/CCaptchaAction)
'width'=>75,
'height'=>30,
),
//以下为测试用:我们在外边随便定义一个类,都可以通过这种方式访问
// user/coo 就会访问Computer.php里边的run()方法
'coo'=>array(
'class'=>'application.controllers.Computer', #别名application代表protected目录
),
);
}
claas Computer extends CActive{ function run(){ echo 'computer start..'; }}
登录模型
array('verifyCode','captcha','message'=>'请输入正确的验证码'), #captcha会找到CcaptchaAction进行验证码的比较。