/** * Creates a new Groups model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($parent_id = null) { $model = new Groups(); if (intval($parent_id) > 0) { $parentGroup = $this->findModel($parent_id); $model->parent_group = $parent_id; $model->is_subgroup = 1; $model->id_speciality = $parentGroup->id_speciality; $model->inflow_year = $parentGroup->inflow_year; } else { $model->is_subgroup = 0; } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->group_id]); } else { return $this->render('create', ['model' => $model]); } }