original_string: public function onRelationManageUpdate()
      {
          $this->forceManageMode = 'form';
          $this->beforeAjax();
          $saveData = $this->manageWidget->getSaveData();
  
          if ($this->viewMode == 'multi') {
              $model = $this->relationModel->find($this->manageId);
              $modelsToSave = $this->prepareModelsToSave($model, $saveData);
              foreach ($modelsToSave as $modelToSave) {
                  $modelToSave->save(null, $this->manageWidget->getSessionKey());
              }
          }
          elseif ($this->viewMode == 'single') {
              $this->viewWidget->setFormValues($saveData);
              $this->viewModel->save(null, $this->manageWidget->getSessionKey());
          }
  
          return $this->relationRefresh();
      }
code: public function onRelationManageUpdate()
      {
          $this->forceManageMode = 'form';
          $this->beforeAjax();
          $saveData = $this->manageWidget->getSaveData();
  
          if ($this->viewMode == 'multi') {
              $model = $this->relationModel->find($this->manageId);
              $modelsToSave = $this->prepareModelsToSave($model, $saveData);
              foreach ($modelsToSave as $modelToSave) {
                  $modelToSave->save(null, $this->manageWidget->getSessionKey());
              }
          }
          elseif ($this->viewMode == 'single') {
              $this->viewWidget->setFormValues($saveData);
              $this->viewModel->save(null, $this->manageWidget->getSessionKey());
          }
  
          return $this->relationRefresh();
      }
code_tokens: public function onRelationManageUpdate ( ) { $ this -> forceManageMode = 'form' ; $ this -> beforeAjax ( ) ; $ saveData = $ this -> manageWidget -> getSaveData ( ) ; if ( $ this -> viewMode == 'multi' ) { $ model = $ this -> relationModel -> find ( $ this -> manageId ) ; $ modelsToSave = $ this -> prepareModelsToSave ( $ model , $ saveData ) ; foreach ( $ modelsToSave as $ modelToSave ) { $ modelToSave -> save ( null , $ this -> manageWidget -> getSessionKey ( ) ) ; } } elseif ( $ this -> viewMode == 'single' ) { $ this -> viewWidget -> setFormValues ( $ saveData ) ; $ this -> viewModel -> save ( null , $ this -> manageWidget -> getSessionKey ( ) ) ; } return $ this -> relationRefresh ( ) ; }
docstring: Updated an existing related model's fields
docstring_tokens: Updated an existing related model s fields