/** * Updates an existing TravellersCountries model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $traveller = \frontend\models\Travellers::findOne($id); $model = new TravellersCountries(); $model->travelled_country = Yii::$app->commoncomponent->getCountriesArray($traveller->travelledCountries); $model->lived_country = Yii::$app->commoncomponent->getCountriesArray($traveller->livedCountries); $model->favourite_country = Yii::$app->commoncomponent->getCountriesArray($traveller->favouriteCountries); $Countries = Yii::$app->commoncomponent->getAllCountriesArray(); $TravellersBestThing = TravellersBestThing::find()->where(['traveller_id' => $id])->one(); if ($model->load(Yii::$app->request->post())) { Yii::$app->commoncomponent->deleteTravellerCountries($id); Yii::$app->commoncomponent->saveTravellerCountries($model->travelled_country, $id, 'travelled_country'); Yii::$app->commoncomponent->saveTravellerCountries($model->lived_country, $id, 'lived_country'); Yii::$app->commoncomponent->saveTravellerCountries($model->favourite_country, $id, 'favourite_country'); return $this->redirect(['travellers/imagegallery', 'id' => $model->traveller_id]); } else { return $this->render('update', ['model' => $model, 'traveller_id' => $id, 'TravellersBestThing' => $TravellersBestThing, 'Countries' => $Countries]); } }