コード例 #1
0
 /**
  * Creates a new Board model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Board();
     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
 /**
  * Creates board
  * @return array|\yii\web\Response
  */
 public function actionCreate()
 {
     //TODO: Check authorization.
     $board = new Board();
     $board->scenario = Board::SCENARIO_CREATE;
     if ($board->load(\Yii::$app->request->post()) && $board->validate()) {
         if ($board->save()) {
             \Yii::$app->response->setStatusCode(201);
             // TODO: we need to return full entity, not just name
             return $this->actionGet($board->name);
         }
     }
     return $board->errors;
 }