/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Category(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'index' page. * @return mixed */ public function actionNew() { $model = new Category(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('new', ['model' => $model]); } }
public function actionCreate() { $category = new Category(); if ($category->load(Yii::$app->request->post()) && $category->validate()) { $category->save(); Yii::$app->getSession()->setFlash('success', 'You added new category successfully'); return $this->redirect(Yii::$app->urlManager->createUrl('category')); } return $this->render('create', ['category' => $category]); }