/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new StudentDocsTrans(); $stud_doc = new StudentDocs(); //$this->layout='receipt_layout'; // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation(array($model, $stud_doc)); // $docs = CUploadedFile::getInstancesByName('student_docs_path'); if (isset($_POST['StudentDocs'])) { //var_dump($stud_doc->student_docs_path); //exit; $stud_doc->attributes = $_POST['StudentDocs']; $stud_doc->student_docs_path = CUploadedFile::getInstance($stud_doc, 'student_docs_path'); //var_dump($stud_doc->student_docs_path); //exit; // if($stud_doc->student_docs_path != NULL) { $valid = $stud_doc->validate(); if ($valid) { $stud_doc->student_docs_path->saveAs(Yii::getPathOfAlias('webroot') . '/college_data/stud_docs/' . $stud_doc->student_docs_path); $date = $_POST['StudentDocs']['student_docs_submit_date']; $submit_date = date("Y-m-d", strtotime($date)); $stud_doc->student_docs_submit_date = $submit_date; $stud_doc->save(); $model->student_docs_trans_user_id = $_REQUEST['id']; $model->student_docs_trans_stud_docs_id = $stud_doc->student_docs_id; $model->save(); $this->redirect(array('studentTransaction/studentdocs', 'id' => $model->student_docs_trans_user_id)); } /*else { $stud_doc->addError('student_docs_path',"Please select any document1"); }*/ } $this->render('create', array('model' => $model, 'stud_doc' => $stud_doc)); }