/** * Creates a new StudentAddress model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($studentId) { $model = new StudentAddress(); $student = Student::findOne($studentId); if (!Yii::$app->user->can('updateStudent', ['student' => $student])) { Yii::$app->session->setFlash('error', 'Access denied.'); return $this->redirect(['/student/index'], 403); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index', 'studentId' => $studentId]); } else { return $this->render('create', ['student' => $student, 'model' => $model]); } }