Yii Framework Forum: function isAttributeRequired() problem on login access - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

function isAttributeRequired() problem on login access pls help! Rate Topic: -----

#1 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 13 September 2010 - 10:49 PM

everytime i access the login page [site/login] this error shows up:


Quote

Fatal error: Call to a member function isAttributeRequired() on a non-object in C:\xampp\yii\framework\yiilite.php on line 4517

0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 14 September 2010 - 01:03 AM

Check your login page... could be that you spelled wrong a model in calling activeLabelEx..
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 02:21 AM

View Postmdomba, on 14 September 2010 - 01:03 AM, said:

Check your login page... could be that you spelled wrong a model in calling activeLabelEx..



oh yeah some letter were in lower case... thanks for that. but i still have a problem.. actually it showed up after i fixed the activeLabelEx stuff.

this php error shows up.
CException
Description

Property "CActiveForm.activeLabelEx" is not defined.
Source File

C:\xampp\yii\framework\yiilite.php(600)

00588:                 array('{class}'=>get_class($this), '{property}'=>$name)));
00589:     }
00590:     public function __call($name,$parameters)
00591:     {
00592:         if($this->_m!==null)
00593:         {
00594:             foreach($this->_m as $object)
00595:             {
00596:                 if($object->getEnabled() && method_exists($object,$name))
00597:                     return call_user_func_array(array($object,$name),$parameters);
00598:             }
00599:         }
00600: if(class_exists('Closure', false) && $this->$name instanceof Closure)
00601:             return call_user_func_array($this->$name, $parameters);
00602:         throw new CException(Yii::t('yii','{class} does not have a method named "{name}".',
00603:             array('{class}'=>get_class($this), '{name}'=>$name)));
00604:     }
00605:     public function asa($behavior)
00606:     {
00607:         return isset($this->_m[$behavior]) ? $this->_m[$behavior] : null;
00608:     }
00609:     public function attachBehaviors($behaviors)
00610:     {
00611:         foreach($behaviors as $name=>$behavior)
00612:             $this->attachBehavior($name,$behavior);

Stack Trace

#0 C:\xampp\yii\framework\yiilite.php(600): CComponent->__get('activeLabelEx')
#1 [internal function]: CComponent->__call('activeLabelEx', Array)
#2 C:\xampp\htdocs\viasatondemand\admin\protected\views\site\index.php(19): CActiveForm->activeLabelEx(NULL, 'username')
#3 C:\xampp\yii\framework\yiilite.php(2851): require('C:\xampp\htdocs...')
#4 C:\xampp\yii\framework\yiilite.php(2830): CBaseController->renderInternal('C:\xampp\htdocs...', NULL, true)
#5 C:\xampp\yii\framework\yiilite.php(3220): CBaseController->renderFile('C:\xampp\htdocs...', NULL, true)
#6 C:\xampp\yii\framework\yiilite.php(3197): CController->renderPartial('index', NULL, true)
#7 C:\xampp\htdocs\viasatondemand\admin\protected\controllers\SiteController.php(28): CController->render('index')
#8 C:\xampp\yii\framework\yiilite.php(3430): SiteController->actionIndex()
#9 C:\xampp\yii\framework\yiilite.php(3002): CInlineAction->run()
#10 C:\xampp\yii\framework\yiilite.php(2987): CController->runAction(Object(CInlineAction))
#11 C:\xampp\yii\framework\yiilite.php(2977): CController->runActionWithFilters(Object(CInlineAction), Array)
#12 C:\xampp\yii\framework\yiilite.php(1542): CController->run('')
#13 C:\xampp\yii\framework\yiilite.php(1434): CWebApplication->runController('')
#14 C:\xampp\yii\framework\yiilite.php(1049): CWebApplication->processRequest()
#15 C:\xampp\htdocs\viasatondemand\admin\index.php(11): CApplication->run()
#16 {main}



this is the whole code in login.php

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

<br  /><br  /><center><p><em>Welcome to the Viasatondemand Administration Section.</em></p></center>


<h1>Login</h1>

<p>Please fill out the following form with your login credentials:</p>

<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->activeLabelEx($model,'username'); ?>
		<?php echo $form->textField($model,'username'); ?>
		<?php echo $form->error($model,'username'); ?>
	</div>

	<div class="row">
		<?php echo $form->activeLabelEx($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 -->

0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 14 September 2010 - 02:29 AM

CActiveForm does not have activeLabelEx but it has labelEx that is a wrapper for activelabelEx - http://www.yiiframew...#labelEx-detail

so use $form->labelEx
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 02:34 AM

View Postmdomba, on 14 September 2010 - 02:29 AM, said:

CActiveForm does not have activeLabelEx but it has labelEx that is a wrapper for activelabelEx - http://www.yiiframew...#labelEx-detail

so use $form->labelEx



oh okay lemme try that.. thanks for replying :D
0

#6 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 02:40 AM

Quote

Fatal error: Call to a member function isAttributeRequired() on a non-object in C:\xampp\yii\framework\yiilite.php on line 4517


I changed activeLabelEx to labeEx but still that error shows up [again].. *sigh*
0

#7 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 02:54 AM

i got it now... i was stupidly trying to fit the active form in the index file my bad -_-.. now i really have to find a way to put a log in form in that admin index


thanks for replying.. it was a big help :)
0

#8 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 14 September 2010 - 03:01 AM

Check in SiteController->actionLogin what are you sending as $model when calling render...

should be
$model=new LoginForm;
...
$this->render('login',array('model'=>$model));

Find more about me.... btw. Do you know your WAN IP?
0

#9 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 03:30 AM

is this it?... i can clearly see that it's $form not $model.. and this is the default code inside SiteController

public function actionLogin()
	{
		$form=new LoginForm;
		// collect user input data
		if(isset($_POST['LoginForm']))
		{
			$form->attributes=$_POST['LoginForm'];
			// validate user input and redirect to the admin page is it's a valid login.
			if($form->validate())
				//$this->redirect(Yii::app()->user->returnUrl);
				$this->redirect( Yii::app()->homeUrl . 'event/admin' );
		}
		// display the login form
		$this->render('login',array('form'=>$form));
	}

0

#10 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 14 September 2010 - 03:57 AM

OK... something is wrong here...

with
$this->render('login',array('form'=>$form));
you are creating a PHP variable $form that you can use in login.php...

so instead of $model you would be using $form...

BUT!!!

on the beginning of the login.php you have
$form=$this->beginWidget('CActiveForm', ...
and with that you loose the value you sent to login.php...

but in this case you would get the error

Quote

Undefined variable: model
as $model is not defined anywhere...

as you are not getting that error then $model is defined somewhere :unsure:
Find more about me.... btw. Do you know your WAN IP?
0

#11 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 04:02 AM

View Postmdomba, on 14 September 2010 - 03:57 AM, said:

OK... something is wrong here...

with
$this->render('login',array('form'=>$form));
you are creating a PHP variable $form that you can use in login.php...

so instead of $model you would be using $form...

BUT!!!

on the beginning of the login.php you have
$form=$this->beginWidget('CActiveForm', ...
and with that you loose the value you sent to login.php...

but in this case you would get the error as $model is not defined anywhere...

as you are not getting that error then $model is defined somewhere :unsure:



yeah weird.. freakish weird... sigh.. well okay nevermind that... thanks! :D i would like to ask something as a last request.. how do i put a login form at your index.php?[view]

T_T i'm so stuck with this.
0

#12 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 14 September 2010 - 04:22 AM

Why would you put a login form on index.php?

I presume you don't want "guests" to see anything on your site before thay log in and that's why you want the login form in index.php

For that you can use this in actionIndex
     if(Yii::app()->user->isGuest)
            $this->actionLogin();

Find more about me.... btw. Do you know your WAN IP?
0

#13 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 04:26 AM

View Postmdomba, on 14 September 2010 - 04:22 AM, said:

Why would you put a login form on index.php?

I presume you don't want "guests" to see anything on your site before thay log in and that's why you want the login form in index.php

For that you can use this in actionIndex
     if(Yii::app()->user->isGuest)
            $this->actionLogin();




half correct.. :) i'm just implementing the login form in an the admin section i created. it's a separate index.php from the main application..

thanks for the heads up :D
0

#14 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 04:29 AM

View Postkael, on 14 September 2010 - 04:26 AM, said:

half correct.. :) i'm just implementing the login form in an the admin section i created. it's a separate index.php from the main application..

thanks for the heads up :D



oh man... i did what you said and added
<?php    if(Yii::app()->user->isGuest)
            $this->actionLogin(); ?>


but the same error shows up.

Quote

Login

Please fill out the following form with your login credentials:

Fields with * are required.

Fatal error: Call to a member function isAttributeRequired() on a non-object in C:\xampp\yii\framework\yiilite.php on line 4517

i think the problem is within SiteController.php
0

#15 User is offline   kael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 13-September 10
  • Location:静岡、 静岡、 日本 と フィリピン

Posted 14 September 2010 - 04:37 AM

I GOT IT!

changed $form=new LoginForm; to $model=new LoginForm;

and added an assets folder in the same level as admin's index.php :) outside protected. :) thanks!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users