Ejemplo n.º 1
0
 /**
  * Creates a new Model model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Model();
     $cover = new BookCover();
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->getRequest()->post('BookCover')) {
             $cover->cover = UploadedFile::getInstance($cover, 'cover');
             $cover->fill($model);
         }
         if ($model->save()) {
             return $this->redirect(['index']);
         }
     } else {
         return $this->render('create', ['cover' => $cover, 'model' => $model, 'authorsAssoc' => \app\models\authors\Model::getAllAsAssoc()]);
     }
 }