public function actionCreate($parentId) { $partner = Partner::findOne($parentId); $model = new Service(); $model->parentId = $parentId; $model->categoryId = $partner->parentId; if ($model->load($_POST) && $model->save()) { return $this->redirect(['/discount/admin/partner/update', 'id' => $parentId, 'section' => 'two']); } else { return $this->render('create', ['model' => $model]); } }
/** * Finds the Partner model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Partner the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Partner::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }