Fatal error: a member function getAttributeLabel()

Fatal error: Call to a member function getAttributeLabel() on a non-object in E:\xampp\htdocs\yii\framework\web\helpers\CHtml.php on line 1136

[b]

[/b]

I could not get any idea, so I need your help.

Just this error line does not say much…

Post here full stack trace… or the some code that you added before the error appeared…


From the error line I see that this is a call to activeLabel()

File location: mySiteName/protected/views/site/index.php Here I wanted to put those forms. The code is listed below:


<?php $this->pageTitle=Yii::app()->name; ?>


<p style="width:200px; float:left; font-family:fantasy; font-size:12px; color:"><?php echo CHtml::encode(Yii::app()->name); ?> helps you connect and share with the people in your life.</p>


<div class="registrationform">

	<div class="form">

	<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'login-form',

	'enableAjaxValidation'=>true,

)); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<div class="row">

		<?php echo $form->labelEx($model,'username'); ?>

		<?php echo $form->textField($model,'username'); ?>

		<?php echo $form->error($model,'username'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'password'); ?>

		<?php echo $form->passwordField($model,'password'); ?>

		<?php echo $form->error($model,'password'); ?>

		<p class="hint">

			Hint: You may login with <tt>demo/demo</tt> or <tt>admin/admin</tt>.

		</p>

	</div>


	<div class="row rememberMe">

		<?php echo $form->checkBox($model,'rememberMe'); ?>

		<?php echo $form->label($model,'rememberMe'); ?>

		<?php echo $form->error($model,'rememberMe'); ?>

	</div>


	<div class="row buttons">

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

	</div>


<?php $this->endWidget(); ?>

</div><!-- form -->

</div>

This code seems OK… check the call that renders this view if you are sending some value to $model

I have not made model. Can it be by any name? or i need to match with the folder name, as my folder is site so does my module should be site?

If you don’t have a model… than you cannot use this code…

The code


$form->labelEx($model,'username');

Renders an HTML label for a model attribute in this case $model->username.

But as there is already LoginForm.php (protected/models/LoginForm.php). It should work , shouldn’t it?

I tried to echo the value of $model; but it returns null (nothing).

LoginForm.php is the model class…

The actionLogin() in SiteController.php creates a new instance of that model and renders the view with this line


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

So that in the view - index.php $model is an instance of the model LoginForm…

Hope you understant this…

Try to study the default code generated by yiic… and if you haven’t done so… read the Definitive guide to Yii

if you need help… just ask…

Thank you mdomba for your kind support. I will try once and if get prob. I will seek your help. Thanks again.

By the way:

This forum is for reporting bugs.

Not in your own code, though. B)

overriding getId() method in UserIdentity can raise this problem