/** Создание нового раздела */ public function actionCreate($cat_id = 0) { $model = new Categories(); $model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => 'gallery']); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect([$model->handler . '/list', 'id' => $model->id]); } else { $model->parent_id = $cat_id; return $this->render('create', ['model' => $model]); } }
/** * Creates a new Resources model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($id) { if ($id == 0) { throw new \yii\web\BadRequestHttpException("Неправильный запрос"); } $model = new Categories(); $model->parent_id = $id; $model->handler = $this->id; $model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => $this->id]); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['list', 'id' => $model->parent_id]); } else { return $this->render('create', ['model' => $model]); } }