コード例 #1
0
 public function actionNew()
 {
     $app = Yii::$app;
     $request = $app->request;
     if ($request->getIsPost()) {
         $post = $request->post();
         $article = new Article(['scenario' => 'new']);
         $article->load($post);
         $date = date('Y-m-d H:i:s', time());
         $article->uid = $app->user->id;
         $article->create_date = $date;
         $article->modified_date = $date;
         $article->save();
         $this->refresh();
     } else {
         $categoryList = Category::getCategoryList();
         $this->smartyAssign('categoryList', $categoryList);
         $this->showHtml();
     }
 }