/** * Creates a new Product model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($category_id = null) { $model = new Part(); if ($model->load(Yii::$app->request->post())) { if ($model->save()) { return $this->redirect(['index', 'category' => $model->category_id]); } } else { if ($category_id) { $model->category_id = $category_id; } return $this->render('create', ['model' => $model]); } }