/**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $recordSave = false;
     $this->layout = '';
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['TransportStations'])) {
         $model->attributes = $_POST['TransportStations'];
         if ($model->save()) {
             LinkTransportStationsToTransportTypes::model()->deleteAll("transportStation=" . $id);
             if (isset($_POST['TransportStations']['type'])) {
                 $types = $_POST['TransportStations']['type'];
                 foreach ($types as $typeKey => $typeValue) {
                     if ($typeValue == 1) {
                         $user2role = new LinkTransportStationsToTransportTypes();
                         $user2role->unsetAttributes();
                         $user2role->transportStation = $id;
                         $user2role->transportType = $typeKey;
                         $user2role->status = 1;
                         $user2role->save();
                     }
                 }
             }
             $recordSave = true;
         }
     }
     $this->render('update', array('model' => $model, 'recordSave' => $recordSave));
 }