/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $examAll = Exam::model()->findAll('status=1'); $examOption = array(); foreach ($examAll as $exam) { $examOption[$exam->exam_id] = $exam->name; } $answerTypeAll = AnswerType::model()->findAll(); $answerTypeOption = array(); foreach ($answerTypeAll as $answerType) { $answerTypeOption[$answerType->answer_type_id] = $answerType->answer_type_name; } $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Session'])) { $model->attributes = $_POST['Session']; if ($model->save()) { $this->redirect(array('index')); } } $this->render('update', array('model' => $model, 'examOption' => $examOption, 'answerTypeOption' => $answerTypeOption)); }