/** * Creates a new Part model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($role) { if (Yii::$app->user->identity && Yii::$app->user->identity->isStaff()) { $model = new Part(); $manufacturers = ArrayHelper::map(Manufacturer::find()->all(), 'manufacturer_id', 'manufacturer_name'); $parametersData = $model->getParametersData($role); $model->setAttribute('role_fk', $role); $partRole = Role::find()->where(['role_id' => $role])->one(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->part_id]); } else { return $this->render('create', ['model' => $model, 'manufacturers' => $manufacturers, 'role' => $partRole, 'parametersData' => $parametersData]); } } else { throw new \yii\web\HttpException(403, 'STAFF ONLY'); } }