コード例 #1
0
 /**
  * Creates a new Newsletter model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Newsletter();
     if ($model->load(Yii::$app->request->post())) {
         $model->created_by = Yii::$app->user->identity->username;
         $model->created_date = date('Y-m-d h:m:s');
         $model->last_modified_by = Yii::$app->user->identity->username;
         $model->last_modified_date = date('Y-m-d h:m:s');
         $model->status = Status::STATUS_ACTIVE;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }