controllers/BookController.php
/**
     * Updates an existing Books model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
Updates an existing Books model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
@throws NotFoundHttpException if the model cannot be found
Updates an existing Books model . If update is successful the browser will be redirected to the ' view ' page . @param integer $id @return mixed @throws NotFoundHttpException if the model cannot be found
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        foreach ($model->authors as $auth) {
            $model->idAuthors[] = $auth->id;
        }
        $this->allauthor = self::getAllAuthorsForDropdownList();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        }
        return $this->render('update', [
            'model' => $model,
            'allauthor' => $this->allauthor,
        ]);
    }
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; foreach ( $ model -> authors as $ auth ) { $ model -> idAuthors [ ] = $ auth -> id ; } $ this -> allauthor = self :: getAllAuthorsForDropdownList ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } return $ this -> render ( 'update' , [ 'model' => $ model , 'allauthor' => $ this -> allauthor , ] ) ; }
Updates an existing Books model.
Updates an existing Books model .
//Текущий список авторов книги //Массив все авторов для dropdownList