Example #1
0
 /**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Page();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #2
0
 public function actionSave()
 {
     if (!empty($this->app->request->post->id)) {
         $item = Page::findByPK($this->app->request->post->id);
     } else {
         $item = new Page();
     }
     $item->fill($this->app->request->post);
     $item->save();
     $this->redirect('/admin/pages');
 }