public function actionview_topic($id) { $modelAnswer = new ForumAnswer(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ForumAnswer'])) { $modelAnswer->attributes = $_POST['ForumAnswer']; $modelAnswer->a_id = $id; $modelAnswer->a_datetime = date('Y-m-d h:i:sa'); $x = ForumQuestion::model()->findByPK($id); $x->reply = $x->reply + 1; $x->save(); if ($modelAnswer->save()) { $this->redirect(array('view_topic', 'id' => $id)); } } $this->render('view_topic', array('modelAnswer' => $modelAnswer, 'model' => ForumQuestion::model()->findByPK($id))); }