Hi everybody,
I just started to learn how to use Yii yesterday and I’m already in love with it. Before I was using CodeIgniter (and I still am).
I have been following the Blog Tutorial (PDF version, if that makes a difference) and all has gone well until half an hour ago. I reached the end of the first milestone and when I tried to log in using demo as username and password, I got the following error:
CException
Description
Property "User.demo" is not defined.
Source File
/Users/aziz/Sites/yii/yii/framework/db/ar/CActiveRecord.php(106)
00094: */
00095: public function __get($name)
00096: {
00097: if(isset($this->_attributes[$name]))
00098: return $this->_attributes[$name];
00099: else if(isset($this->getMetaData()->columns[$name]))
00100: return null;
00101: else if(isset($this->_related[$name]))
00102: return $this->_related[$name];
00103: else if(isset($this->getMetaData()->relations[$name]))
00104: return $this->getRelated($name);
00105: else
00106: return parent::__get($name);
00107: }
00108:
00109: /**
00110: * PHP setter magic method.
00111: * This method is overridden so that AR attributes can be accessed like properties.
00112: * @param string property name
00113: * @param mixed property value
00114: */
00115: public function __set($name,$value)
00116: {
00117: if($this->setAttribute($name,$value)===false)
00118: {
Stack Trace
#0 /Users/aziz/Sites/yii/yii/framework/db/ar/CActiveRecord.php(106): CComponent->__get('demo')
#1 /Users/aziz/Sites/yii/blog/protected/models/User.php(74): CActiveRecord->__get('demo')
#2 /Users/aziz/Sites/yii/blog/protected/components/UserIdentity.php(19): User->validatePassword('demo')
#3 /Users/aziz/Sites/yii/blog/protected/models/LoginForm.php(50): UserIdentity->authenticate()
#4 /Users/aziz/Sites/yii/yii/framework/validators/CInlineValidator.php(39): LoginForm->authenticate('password', Array)
#5 /Users/aziz/Sites/yii/yii/framework/validators/CValidator.php(168): CInlineValidator->validateAttribute(Object(LoginForm), 'password')
#6 /Users/aziz/Sites/yii/yii/framework/base/CModel.php(150): CValidator->validate(Object(LoginForm), NULL)
#7 /Users/aziz/Sites/yii/blog/protected/controllers/SiteController.php(80): CModel->validate()
#8 /Users/aziz/Sites/yii/yii/framework/web/actions/CInlineAction.php(32): SiteController->actionLogin()
#9 /Users/aziz/Sites/yii/yii/framework/web/CController.php(300): CInlineAction->run()
#10 /Users/aziz/Sites/yii/yii/framework/web/CController.php(278): CController->runAction(Object(CInlineAction))
#11 /Users/aziz/Sites/yii/yii/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#12 /Users/aziz/Sites/yii/yii/framework/web/CWebApplication.php(320): CController->run('login')
#13 /Users/aziz/Sites/yii/yii/framework/web/CWebApplication.php(120): CWebApplication->runController('site/login')
#14 /Users/aziz/Sites/yii/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()
#15 /Users/aziz/Sites/yii/blog/index.php(11): CApplication->run()
#16 {main}
2010-01-23 20:48:23 Apache Yii Framework/1.1.0
I could post some code if you ask me which part of the app you would need, but my UserIdentity class is exactly the same as the one in the demos folder blog app as are the validatePassword and hashPassword actions.
Does anybody have a clue about what could be the problem please?