Creating Custom Action In Controller

I’m new to yii.

I’ve created a controller called CatalogController. I want to create a custom action called actionClear(). I’ve followed steps from documentation and searching on-line but when I navigate to catalog/clear, it redirects back to homepage of site. I don’t know what other steps I should be taking.

I’ve done the following so far:

in CatalogController:




public function actionClear() {

     $dataProvider=new CActiveDataProvider('Catalog');

     $this->render('clear',array('dataProvider'=>$dataProvider));

}

overridden rules() method in controller:


public function actions()

{

    return array(

        'clear'=>'application.controllers.post.ClearAction',

    );

}

a new custom action under protected/controllers/post


class ClearAction extends CAction

{

    public function run()

    {

        echo 'fart';die;

    }

}

Any help would be greatly appreciated.

do u allow this action in accessRules( ) and why are you using the same action (clear) in controller method and separate action try using anyone.

You have to remove "public function actionClear" from controller.