public function actionInsert() { if (Yii::$app->user->can('surveyCreate')) { $data = Yii::$app->request->post(); $model = new Question(); $model->content = $data['content']; $model->order = $data['order']; $model->Survey_id = $data['surveyId']; $model->required = $data['require']; $model->temp_input_required = 'temp'; if ($model->save()) { return $model->getPrimaryKey(); } return -1; } else { throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.')); } }