/** * Updates an existing Tour model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $booking = new Booking(); $bookingFields = $booking->attributeLabels(); unset($bookingFields['id']); unset($bookingFields['tour_id']); $data = Yii::$app->request->post(); if ($model->load($data)) { if (isset($data['sort'])) { $model->sort = Json::encode($data['sort']); } $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'bookingFields' => $bookingFields]); } }