コード例 #1
0
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
 }
コード例 #2
0
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($date)
 {
     $model = new Event();
     $model->created_date = $date;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
 }
コード例 #3
0
ファイル: EventController.php プロジェクト: tqsq2005/Yii2adv
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', '事件<' . $model->title . '>添加成功!  ');
         return $this->redirect(['index']);
     } else {
         return $this->renderAjax('create', ['model' => $model->loadDefaultValues()]);
     }
 }