/** * @return \yii\db\ActiveQuery|AuthorsModel */ public function getAuthorModel() { return $this->hasOne(AuthorsModel::className(), ['id' => 'author_id']); }
/** * Updates an existing Model model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $cover = new BookCover(); if ($model->load(Yii::$app->request->post())) { $bookCoverPost = Yii::$app->getRequest()->post('BookCover'); $cover->cover = UploadedFile::getInstance($cover, 'cover'); if ($bookCoverPost && $cover->cover) { $cover->fill($model); } var_dump($model->save(), $model->release_date); if ($model->save()) { var_dump(Url::previous(static::FILTERED_LINK_KEY)); return $this->redirect(Url::previous(static::FILTERED_LINK_KEY)); } } else { return $this->render('update', ['cover' => $cover, 'model' => $model, 'authorsAssoc' => \app\models\authors\Model::getAllAsAssoc()]); } }