/** * Creates a new Resources model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Resources(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Создание новой страницы в категории $id. */ public function actionCreate($id) { $model = new Resources(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['list', 'id' => $id]); } else { $model->category_id = $id; return $this->render('create', ['model' => $model]); } }
public function actionNewAlbum($id) { if ($id == 0) { throw new BadRequestHttpException("Неправильный запрос"); } $model = new Resources(['scenario' => 'album']); $model->category_id = $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->id]); } else { return $this->render('new-album', ['model' => $model]); } }