/** * Creates a new Tech model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($id) { $model = new Tech(); $model->loadDefaultValues(); $model->contact_id = $id; if ($model->load(Yii::$app->request->post()) && $model->save()) { //return $this->redirect(['contact/view', 'id' => $model->contact_id]); return $this->redirect(Url::previous()); } elseif (!Yii::$app->request->isPost) { $model->load(Yii::$app->request->get()); } if (Yii::$app->request->isAjax) { return $this->renderAjax('_form', ['model' => $model]); } return $this->render('create', ['model' => $model]); }
/** * Creates a new Tech model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Tech(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }