コード例 #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->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
 /**
  * Install event from config
  * @param var $data
  * @return bool
  */
 protected function installEvent($event)
 {
     $data['Event'] = $event;
     $model = new Event();
     if ($model->load($data) && $model->save()) {
         Yii::$app->session->setFlash('success', Yii::t('plugin', 'New event installed'));
     } else {
         return ['error' => $model->errors];
         // var_dump($model->errors);
     }
 }