/** * Creates a new TrainTeachers model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $train_id = Yii::$app->request->get('train_id'); $trainName = Train::getOneTrainNameById($train_id); $model = new TrainTeachers(); $model->trainName = $trainName; $model->trainId = $train_id; if (Yii::$app->request->isPost) { if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } else { return $this->render('create', ['model' => $model]); } }