/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Coursemanager(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Coursemanager'])) { $model->attributes = $_POST['Coursemanager']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Performs the AJAX validation. * @param CModel the model to be validated */ public function actionManage() { $model = new Coursemanager(); if (isset($_POST['assign'])) { if (isset($_POST['user']) and $_POST['user'] != NULL) { $user = $_POST['user']; } if (isset($_POST['cid']) and $_POST['cid'] != NULL) { // var_dump($_POST['cid']); $no_of_course = count($_POST['cid']); for ($i = 0; $i < $no_of_course; $i++) { $model = new Coursemanager(); //print_r($_POST['cid'][$i]); exit; $model->user_id = $user; $model->course = $_POST['cid'][$i]; $model->save(); } } } $this->render('manage', array('model' => $model, 'id' => $model->id)); }