original_string: public function create_onSave($context = null)
      {
          $this->context = strlen($context) ? $context : $this->getConfig('create[context]', self::CONTEXT_CREATE);
  
          $model = $this->controller->formCreateModelObject();
          $model = $this->controller->formExtendModel($model) ?: $model;
  
          $this->initForm($model);
  
          $this->controller->formBeforeSave($model);
          $this->controller->formBeforeCreate($model);
  
          $modelsToSave = $this->prepareModelsToSave($model, $this->formWidget->getSaveData());
          Db::transaction(function () use ($modelsToSave) {
              foreach ($modelsToSave as $modelToSave) {
                  $modelToSave->save(null, $this->formWidget->getSessionKey());
              }
          });
  
          $this->controller->formAfterSave($model);
          $this->controller->formAfterCreate($model);
  
          Flash::success($this->getLang("{$this->context}[flashSave]", 'backend::lang.form.create_success'));
  
          if ($redirect = $this->makeRedirect('create', $model)) {
              return $redirect;
          }
      }
code: public function create_onSave($context = null)
      {
          $this->context = strlen($context) ? $context : $this->getConfig('create[context]', self::CONTEXT_CREATE);
  
          $model = $this->controller->formCreateModelObject();
          $model = $this->controller->formExtendModel($model) ?: $model;
  
          $this->initForm($model);
  
          $this->controller->formBeforeSave($model);
          $this->controller->formBeforeCreate($model);
  
          $modelsToSave = $this->prepareModelsToSave($model, $this->formWidget->getSaveData());
          Db::transaction(function () use ($modelsToSave) {
              foreach ($modelsToSave as $modelToSave) {
                  $modelToSave->save(null, $this->formWidget->getSessionKey());
              }
          });
  
          $this->controller->formAfterSave($model);
          $this->controller->formAfterCreate($model);
  
          Flash::success($this->getLang("{$this->context}[flashSave]", 'backend::lang.form.create_success'));
  
          if ($redirect = $this->makeRedirect('create', $model)) {
              return $redirect;
          }
      }
code_tokens: public function create_onSave ( $ context = null ) { $ this -> context = strlen ( $ context ) ? $ context : $ this -> getConfig ( 'create[context]' , self :: CONTEXT_CREATE ) ; $ model = $ this -> controller -> formCreateModelObject ( ) ; $ model = $ this -> controller -> formExtendModel ( $ model ) ? : $ model ; $ this -> initForm ( $ model ) ; $ this -> controller -> formBeforeSave ( $ model ) ; $ this -> controller -> formBeforeCreate ( $ model ) ; $ modelsToSave = $ this -> prepareModelsToSave ( $ model , $ this -> formWidget -> getSaveData ( ) ) ; Db :: transaction ( function ( ) use ( $ modelsToSave ) { foreach ( $ modelsToSave as $ modelToSave ) { $ modelToSave -> save ( null , $ this -> formWidget -> getSessionKey ( ) ) ; } } ) ; $ this -> controller -> formAfterSave ( $ model ) ; $ this -> controller -> formAfterCreate ( $ model ) ; Flash :: success ( $ this -> getLang ( "{$this->context}[flashSave]" , 'backend::lang.form.create_success' ) ) ; if ( $ redirect = $ this -> makeRedirect ( 'create' , $ model ) ) { return $ redirect ; } }
docstring: AJAX handler "onSave" called from the create action and
  primarily used for creating new records.
  
  This handler will invoke the unique controller overrides
  `formBeforeCreate` and `formAfterCreate`.
  
  @param string $context Form context
  @return mixed
docstring_tokens: AJAX handler onSave called from the create action and primarily used for creating new records .