2013-12-12 37 views
0

只有當我刪除filters()方法時,才能顯示驗證碼。其他時間驗證碼不起作用。並且我的php gd支持是啓用的。 順便說一下,如果我直接訪問測試/驗證碼,它只能顯示一個圖片框,而不是內容,也許無法加載圖片..Yii的驗證碼不會顯示,除非刪除accessControl

這裏是我的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('*') 
     ) 
    ); 
} 

}

回答

0

我想你在AccessRules()中有1到多個數組。應該是...

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