using “extends CAction” class of Yii framework

in this tutorial of Yii framework


i want to put my Actions from a Controller to a separate action files

and as the instructions said "create a Action class"

and this is my action class file

    class LoginAction extends CAction



        private $contents = array();

        public function run(){

            $loginmodel = new LoginForm;


            //answer ajax validating request

            if(isset($_POST['ajax']) && $_POST['ajax']==='login-form'){

                echo CActiveForm::validate($loginmodel);




            //collect user input data to do login



                $loginmodel->attributes = $_POST["LoginForm"];

                // validate user input and redirect to the previous page if valid

                if($loginmodel->validate() && $loginmodel->login()){ //<--invoking here the login and validate function





            $this->contents["loginmodel"] =  $loginmodel;





and in my Controller

    class SandboxController extends Controller{   	

        public function actions(){

            // return external action classes, e.g.:

                return array(


                // page action renders "static" pages stored under 'protected/views/site/pages'

                // They can be accessed via: index.php?r=site/page&view=FileName







and i browse the separate action controller using


and my error is

 LoginAction and its behaviors do not have a method or closure named  "render".

do i went wrong on something? thanks.

[color="#1C2837"][size="2"]My system:[/size][/color]

[color=#1C2837][size=2]PHP Version 5.3.8 [/size][/color]

[color=#1C2837][size=2]Windows 7 32bit[/size][/color]

[color="#1C2837"][size="2"]Yii 1.1.10 [/size][/color][color="#1C2837"] [/color]

You’re calling $this->render() on a “$this” (CAction) that doesn’t have a member called that. Use:


Instead, also if you want use:

$this->contents["loginmodel"] =  $loginmodel;

change it to:

$this->controller->contents["loginmodel"] =  $loginmodel;

if you want access to it in the view.

Hope this helps you, never actually done it myself.