I’m having a problem with the issue_id field not being set when a comment is added. I have done everything up to chapter 9 pg 224. I can’t seem to figure it out. I almost think it is a difference between framework versions from what the book has and what I am writing to 1.1.8.
From my IssueController.php
public function actionView($id)
{
$issue=$this->loadModel($id);
$comment=$this->createComment($issue);
$this->render('view',array(
'model'=>$this->loadModel($id),
'comment'=>$comment,
));
}
and
protected function createComment($issue)
{
$comment=new Comment;
if(isset($_POST['Comment']))
{
$comment -> attributes = $_POST['Comment'];
if($issue -> addComment($comment))
{
Yii::app() -> user -> setFlash('commentSubmitted', "Your comment has been added.");
$this -> refresh();
}
}
return $comment;
}
from Issue.php
public function addComment($comment)
{
$commnet->issue_id=$this->id;
return $comment->save();
}
in the DB all the fields are set except issue_id which remains set to null