Hello guys,
I am going through the blog demo (very nice one). One issue occurred with my coding tho:
protected function beforeValidate()
{
$parser=new CMarkdownParser;
$this->contentDisplay=$parser->safeTransform($this->content);
if($this->isNewRecord)
{
$this->createTime=$this->updateTime=date('Y-m-d H:i:s');
$this->authorId=Yii::app()->user->id;
}
else
$this->updateTime=date('Y-m-d H:i:s');
return true;
}
Then when I click on Preview button I displayed (in the view) some debugging info myself like
echo "User id: ".$model->authorId
However, the above code returns my username instead of the id. What have I missed? Why does Yii::app()->user-id returns the username instead of the id and how to call the user id?
Thanks,
B.