/**
  * Creates a new Country model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($id)
 {
     $countrymodel = $this->findModel($id);
     $model = new CountryData();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['create', 'id' => $countrymodel->id]);
     } else {
         return $this->render('create', ['model' => $model, 'countrymodel' => $countrymodel]);
     }
 }
Example #2
0
 public function getData()
 {
     return $this->hasMany(CountryData::className(), ['country_id' => 'id']);
 }
 /**
  * Finds the CountryData model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CountryData the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CountryData::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }