/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Formats(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Formats'])) { $model->attributes = $_POST['Formats']; //echo $_POST['attachments']; //exit; $fileids = explode(",", $_POST['attachments']); $model->formatfile_id = $fileids[1]; // echo print_r($_POST); if ($model->save()) { foreach ($_POST['assigned'] as $i => $y) { //echo $y."\n"; $z = new Usertasks(); $z->designation_id = $y; $z->scheme_id = $model->schemeid; $z->task_type = "Formats"; $z->task_id = $model->id; $z->status = 0; //echo print_r($z); //exit; $z->save(); } //$this->redirect(array('view','id'=>$model->id)); } } $this->render('create', array('model' => $model)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Usertasks::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }