Example #1
0
 public function actionCreate()
 {
     $model = new Page();
     $model->loadDefaultValues();
     if ($model->load(Yii::$app->request->post())) {
         if ($_POST['Page']['parentId'] != 0) {
             $parent = Page::findOne($_POST['Page']['parentId']);
             $success = $model->appendTo($parent);
         } else {
             $success = $model->makeRoot();
         }
         if ($success) {
             Yii::$app->session->addFlash('success', 'صفحه جدید با موفقیت در سیستم درج شد.');
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('create', ['model' => $model]);
 }