Stucked with Yii Framework Form tutorial

[font="Arial,"][size="4"]I keep on reading this tutorial of Yii framework over and over again Yii Framework Form Tutorial[/size][/font]

[font="Arial,"][size="4"]I already created my Model with this following codes[/size][/font]

[font="Arial,"][size="4"]




class LoginForm extends CFormModel{

    public $username;

    public $password;

    public $rememberMe = false;


    private $_identity;


    public function rules(){

        return array(

            /* array(,,)

            * functions required and boolean are built-in validators of the yii framework.

            * you can invoke your own function by defining your own function

            */

            array('username','password','required'),

            array('rememberMe','boolean'),

            array('password','authenticate'),

        );

    }


    public function authenticate(){

        $this->_identity = new UserIdentity($this->username,$this->password);

        if(!$this->_identity->authenticate()){

            $this->addError("password","Incorrect Username or Password");

        }

    }


    public function attributeLabels(){

        return array(

            'username'=>"Username",

            'password'=>"Password",

            'rememberMe'=>"Remember Me",

        );

    }

}



[/size][/font]

[font="Arial,"][size="4"]and my Action function with this codes in my controller[/size][/font]

[font="Arial,"][size="4"]




public function actionLogin(){

            //calls the Login Model that will be used in this action

            $model = new LoginForm;

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

                //collects user input

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

                //validates user input using the model rules and redirects back to

                //previous page when user input is invalid

                if($model->validate()){

   				$this->redirect(Yii::app()->user->returnUrl);   

                }

                //redisplay the login form

                $this->render('login',array('loginModel'=>$model));

            }

        }




[/size][/font]

[font="Arial,"][size="4"]and lastly my view[/size][/font]

[font="Arial,"][size="4"]


 

<div class="form">

    <?php

        $formlogin = $this->beginWidget('CActiveForm'); 	

        echo $formlogin->errorSummary($model);

    ?>            $formlogin = $this->beginWidget('CActiveForm'); 	

        echo $formlogin->errorSummary($model);

    ?>

   		

   						$formlogin->label($model,'username');

                $formlogin->textField($model,'username');

   		?>

   		

   		

   						$formlogin->label($model,'password');

                $formlogin->passwordField($model,'password');

   		?>

   		

   		

   						$formlogin->checkBox($model,'rememberMe');

                $formlogin->label($model,'rememberMe');

   		?>

   		

   		

   						echo CHtml::submitButton('Login');

   		?>

   		

        $this->endWidget();

    ?>

 </div>

[/size]

[/font]

[font="Arial,"][size="4"]and i always came out with this error[/size][/font]

[font="Arial,"][size="4"]


Undefined variable: model

[/size][/font]

[font="Arial,"][size="4"]do i miss something? please let me know… I know this is kinda simple but I am a first-timer in using such component-based MVC frameworks… Thanks[/size][/font]

Hi

on controller

/redisplay the login form

            &#036;this-&gt;render('login',array('loginModel'=&gt;&#036;model));

replace

/redisplay the login form

            &#036;this-&gt;render('login',array('model'=&gt;&#036;model));

Thanks

I try your code and i fell in this error


include(password.php) [[url="function.include"]function.include[/url]]: failed to open stream: No such file or directory


D:\xampp\htdocs\wiltalk\framework\YiiBase.php(418)

i think there is no such a file in framework. may be you installed some extensions or included some files, but haven’t created 'em?

or you are missing quotes near password validator or other string in your code

sorry for taking your time… anyways i got it… i forgot to pass my model instance to my view using my controller’s render function… thank you thank you