示例#1
0
 /**
  * Creates a new Pages model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Pages();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Pages model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Pages();
     $date = date('Y-m-d');
     $model->created = $date;
     $model->updated = $date;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'items' => $this->getItems()]);
     }
 }
示例#3
0
 /**
  * Creates a new Pages model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (!$this->is_access('pages/create')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $model = new Pages();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', '添加成功');
         return $this->redirect(['index']);
     } else {
         Yii::$app->view->params['meta_title'] = '新增文章单页';
         return $this->render('create', ['model' => $model]);
     }
 }
示例#4
0
 /**
  * Creates a new Pages model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Pages();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (!empty($_FILES['UploadForm']['tmp_name']['file'])) {
             $model->removeImages();
             $model->attachImage($_FILES['UploadForm']['tmp_name']['file']);
             if ($model->errors) {
                 var_dump($model->errors);
                 die;
             }
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }