/** * Creates a new Slide model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Book(); if ($model->load(Yii::$app->request->post())) { $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); if ($model->imageFile && !$model->upload()) { Yii::$app->session->setFlash('error', Yii::t('app', 'Image not upload')); return $this->render('create', ['model' => $model]); } $model->setScenario('default'); if ($model->save(false)) { return $this->redirect(['index']); } } return $this->render('create', ['model' => $model]); }