/** * Creates a new Admregulations model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Admregulations(); //$model->status_id = 1; $model->is_active = 1; $model->created = date('Y-m-d'); if ($model->load(Yii::$app->request->post())) { // process uploaded image file instance $file = $model->uploadImage(); if ($model->save()) { // upload only if valid uploaded file instance found if ($file !== false) { $path = $model->getImageFile(); $file->saveAs($path); } Yii::$app->session->setFlash("regulations", 'Documento inserido com sucesso'); return $this->redirect(['view', 'id' => $model->id]); } else { // error in saving model } } return $this->render('create', ['model' => $model]); }