コード例 #1
0
 /**
  * @param null $id
  * @return string|\yii\web\Response
  */
 public function actionCreate($id = null)
 {
     $categories = WordsCategory::find()->all();
     $model = new WordsCategory();
     $model->parent_id = $id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'categories' => $categories]);
     }
 }