コード例 #1
0
 /**
  * ACTION CREATE note | $id=PrimaryKey -> TRIGER FROM VIEW  -ptr.nov-
  */
 public function actionCreate()
 {
     $model = new Employe();
     if ($model->load(Yii::$app->request->post())) {
         $upload_file = $model->uploadImage();
         $data_base64 = $upload_file != '' ? $this->saveimage(file_get_contents($upload_file->tempName)) : '';
         //call function saveimage using base64
         $model->IMG_BASE64 = $data_base64;
         // var_dump($model->validate());
         if ($model->validate()) {
             if ($model->save()) {
                 $model->CREATED_BY = Yii::$app->user->identity->username;
                 $model->save();
                 if ($upload_file !== false) {
                     $path = $model->getUploadedFile();
                     $upload_file->saveAs($path);
                 }
                 // print_r($model->save());
                 // die();
                 //return $this->redirect(['view', 'id' => $model->EMP_ID]);
                 return $this->redirect(['index', 'id' => $model->EMP_ID]);
             }
         }
     } else {
         //$js='$("#create-emp").modal("show")';
         //$this->getView()->registerJs($js);
         //return $this->render('create', [
         //return $this->renderAjax('create', [
         return $this->renderAjax('_form', ['model' => $model]);
     }
 }