示例#1
0
 public function actionAdd($id = null)
 {
     $model = new View();
     if (null !== $id) {
         $id = intval($id);
         if (null !== View::findOne(['id' => $id])) {
             return $this->redirect(Url::toRoute(['edit', 'id' => $id]));
         }
         $model->id = $id;
     }
     if ($model->load(\Yii::$app->request->post())) {
         if ($model->save()) {
             return $this->redirectUser($model->id, true, 'edit');
         }
     }
     return $this->render('edit', ['model' => $model]);
 }