[Help] Try To Add Login Form Not From Template, White Blank Page

Hi All, Im newbie for Yii,

I have try to create Login Form manually, (Not From the General Template).

I want show the Login Form on Fist page.

the Script For Model -> Login_model.php




  <?php

class Login_model extends CActiveRecord

{

  public static function model($className = __CLASS__)

  {

    return parent::model($className);

  }//end fucntion

  

  public function tablename()

  {

    return 'user';

  } //end fucntion

  

  public function attributeLabels()

  {

    return Array(

                  'username'=>'username',

                  'password'=>'password',

                  'hak'=>'hak',

                 );

  }//end fucntion

  

  public function rules()

  {

    return array(

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

       array('username','length','max'=>'10','filter','filter'=>array($obj=new CHtmlPurifier(),'purify')),

       array('password','length','max'=>'10','filter','filter'=>array($obj=new CHtmlPurifier(),'purify')),

       array('hak','length','max'=>'10'),

       


     );

  }//end fucntion

  

  

	

}




?>



And for Controller -> LoginController.php


<?php

class LoginController extends Controller

{

	public $layout="NULL";

	

	public function actionIndex()

	{

		//$this->render('index');

		

		$data = new Login_model;

	 if(isset($_POST['Login_model']))

         {	

		$data->username     =$_POST['Login_model']['username'];

                $data->password     =$_POST['Login_model']['password'];

		

		$list= Yii::app()->db->createCommand('select * from user where username=:username AND 

		       password=:password')->bindValue('password',$password)->queryAll();

			   

	 }//end isset   

            /*if($list->TRUE)

		{

	            using Session		

		}*/


	}

	

}




?>

For View->index.php




<div class="form">

	<?php echo CHtml::beginForm(array('login/index'));

	      echo CHtml::errorSummary($data);

	?>

	

	<div class="row">

		<?php echo CHtml::activeLabel($data,'username');?>

		<?php echo CHtml::activeTextField($data,'username','');?>

    </div><!--end of row-->

	

	<div class="row">

		<?php echo CHtml::activeLabel($data,'password');?>

		<?php echo CHtml::activePasswordField($data,'password','');?>

    </div><!--end of row-->

	

	

		

	<div class="row buttons">

		<?php echo CHtml::submitButton('Log In');?>

		<?php echo CHtml::endForm();?>

	</div>

	

	

</div><!--end of form-->



And it show only Blank White Page. The Apache Error Log File is show like this




PHP Fatal error:  Call to a member function getErrors() on a non-object in /var/www/septiyo/framework/web/helpers/CHtml.php on line 1592




Can Anyone Help me?

And if You have an Idea to create Login not From default Template, I am ready listen to your advice

Thanks For Advance.

Hi and welcome to Yii!

Did you pass the Login_model from your Controller to the view ?

for example at the end of the actionIndex you should add


$this->render('index',array('data'=>$Login_model));

thanks For Reply my Question.

Not Yet, but after I add your advice, the error is


Undefined variable: Login_model 

.

hey It Works, yeah I ForGet To do that. After I Add this Script the Form Show.


$this->render('index',array('data'=>$data));

Thanks A Lot :D