/** * Creates a new Company model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Company(); $modelProvinsi = new Provinsi(['scenario' => 'DepDrop']); $modelKabupaten = new Kabupaten(['scenario' => 'DepDrop']); $modelKecamatan = new Kecamatan(['scenario' => 'DepDrop']); if (Yii::$app->request->isPost) { $model->load(Yii::$app->request->post()); $modelProvinsi->load(Yii::$app->request->post()); $modelKabupaten->load(Yii::$app->request->post()); $modelKecamatan->load(Yii::$app->request->post()); if (Model::validateMultiple([$model, $modelProvinsi, $modelKabupaten]) && $model->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Your data company has been successfully saved')); return $this->redirect(['create']); } else { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Your data company failed to save')); } } return $this->render('create', ['model' => $model, 'modelProvinsi' => $modelProvinsi, 'modelKabupaten' => $modelKabupaten, 'modelKecamatan' => $modelKecamatan]); }