using “extends CAction” class of Yii framework

in this tutorial of Yii framework

http://www.yiiframew…ntroller#action

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);

                Yii::app()->end();

            }

            

            //collect user input data to do login

            if(isset($_POST["LoginForm"]))

            {

                $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->redirect(Yii::app()->user->returnUrl);

                }

            }

            

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

            $this->render('index',$this->contents); 

        }    

        

    }

and in my Controller


    class SandboxController extends Controller{   	

        public function actions(){

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

                return array(

                'authlog'=>'application.controllers.authentication.LoginAction',

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

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

                'page'=>array(

                    'class'=>'CViewAction',

                ),

            );   

        }

    }

and i browse the separate action controller using


http://localhost/mysite/index.php/sandbox/authlog/login

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:


$this->controller->render();

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.