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