Esempio n. 1
0
 /**
  * Updates an existing Post model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $post = $this->findModel(['id' => $id]);
     $categories = Category::find()->orderBy('title')->all();
     if ($post->load(Yii::$app->request->post()) && $post->save()) {
         return $this->redirect(['update', 'id' => $post->id]);
     } else {
         return $this->render('update', ['post' => $post, 'categories' => $categories]);
     }
 }