Problem With Setcomponents() Method In Adminmodule Class

I have admin module, and I want to make error action for that. This is my AdminModule class:




    class AdminModule extends CWebModule

    {

        public function init()

        {

            $this->defaultController = 'home';

            $this->layout = "main";


            $this->setImport(array(

                'admin.models.*',

                'admin.components.*',

            ));


            $this->setComponents(array(

                'errorHandler'=>array(

                    'errorAction'=>'admin/home/error',

                ),

            ));

        }


        public function beforeControllerAction($controller, $action)

        {

            if(parent::beforeControllerAction($controller, $action))

            {

                return true;

            }

            else

                return false;

        }

    }



And this is my home controller in admin module:




    class HomeController extends CController

    {

        public function actionIndex()

        {

            $this->render('index');

        }


        public function actionError()

        {

            if($error=Yii::app()->errorHandler->error)

            {

                if(Yii::app()->request->isAjaxRequest)

                    echo $error['message'];

                else

                    $this->render('error', $error);

            }

        }

    }



But Yii still using error action that configured in protected/config/main.php. I search to solve this problem and found the solution. My question is why $this->setComponents does’nt work? Naturally, this should be worked.

Hi,

you have right code so it should work. just clear cache and try once again.