/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Classmanager(); $_SESSION['course_id'] = 1; if (isset($_GET['ID'])) { $_SESSION['course_id'] = $_GET['ID']; } $course = Course::model()->find(' ID = :id', array('id' => $_SESSION['course_id'])); if (!empty($course)) { $model->ID_course = $course->Name; } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Classmanager'])) { $model->attributes = $_POST['Classmanager']; $model->ID_course = $_SESSION['course_id']; if ($model->save()) { $this->redirect(array('index', 'id' => $model->ID)); } } $this->render('create', array('model' => $model)); }