/** * Creates a new CatalogsAdmin model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new CatalogsAdmin(); if ($model->load(Yii::$app->request->post())) { $id_parent = Yii::$app->request->post('CatalogsAdmin')['id_parent']; $parent = Catalogs::find()->where(['catalog_id' => $id_parent])->one(); $model->prependTo($parent); if ($model->save()) { return $this->redirect(['view', 'catalog_id' => $model->catalog_id]); } } else { return $this->render('create', ['model' => $model]); } }