コード例 #1
0
 /**
  * Creates a new Menu model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Menu();
     $post = Yii::$app->request->post();
     if ($model->load($post) && $model->save()) {
         // Set flash message
         Yii::$app->getSession()->setFlash('menu', Yii::t('app', '"{item}" has been created', ['item' => $model->name]));
         if (isset($post['close'])) {
             return $this->redirect(['index']);
         } elseif (isset($post['new'])) {
             return $this->redirect(['create']);
         } else {
             return $this->redirect(['update', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }