Yii';s captcha没有';除非删除accessControl,否则不会显示


Yii's captcha doesn't show up, unless remove the accessControl

只有当我删除filters()方法时,captcha才能出现。其他时间captcha不起作用。我的php-gd支持是启用的。顺便说一句,如果我直接访问test/catcha,它只显示一个图片框,而不显示内容,可能无法加载图片。。

这是我的TestController.php

class TestController extends Controller
{
public function actionIndex()
{
    $this->render('index');
}
public function actions()
{
    return array(
        // captcha action renders the CAPTCHA image displayed on the contact page
        'captcha'=>array(
            'class'=>'CCaptchaAction',
            'backColor'=>0xFFFFFF,
            'minLength' => 4,
            'maxLength' => 4,
            'testLimit' => 99999
            )
    );
}

public function filters()
{
    // return the filter configuration for this controller, e.g.:
    return array(
        "accessControl",
    );
}
public function accessRules()
{
    return array(
        array('allow',  // allow all users to perform 'index' and 'view' actions
            'actions'=>array('captcha','index'),
            'users'=>array('*')
        )
    );
}

}

我认为accessRules()中有1到多个数组。应该是…

public function accessRules() {
    return array('allow', 
          'actions' => array('captcha'),
          'users' => array('*')
    );
}