/** * Updates an existing Books 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); $model_b_a_rel = BookAuthorRel::findOne(['b_id' => $id]); $authorsArr = Authors::authorArr(); if ($model->load(Yii::$app->request->post()) && $model_b_a_rel->load(Yii::$app->request->post())) { $model->save(); $model_b_a_rel->saveMultiple(1); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'model_b_a_rel' => $model_b_a_rel, 'authorsArr' => $authorsArr]); } }