public function update_onSave($recordId = null, $context = null)
    {
        $this->context = strlen($context) ? $context : $this->getConfig('update[context]', self::CONTEXT_UPDATE);
        $model = $this->controller->formFindModelObject($recordId);
        $this->initForm($model);

        $this->controller->formBeforeSave($model);
        $this->controller->formBeforeUpdate($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->formAfterUpdate($model);

        Flash::success($this->getLang("{$this->context}[flashSave]", 'backend::lang.form.update_success'));

        if ($redirect = $this->makeRedirect('update', $model)) {
            return $redirect;
        }
    }
public function update_onSave($recordId = null, $context = null)
    {
        $this->context = strlen($context) ? $context : $this->getConfig('update[context]', self::CONTEXT_UPDATE);
        $model = $this->controller->formFindModelObject($recordId);
        $this->initForm($model);

        $this->controller->formBeforeSave($model);
        $this->controller->formBeforeUpdate($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->formAfterUpdate($model);

        Flash::success($this->getLang("{$this->context}[flashSave]", 'backend::lang.form.update_success'));

        if ($redirect = $this->makeRedirect('update', $model)) {
            return $redirect;
        }
    }
public function update_onSave ( $ recordId = null , $ context = null ) { $ this -> context = strlen ( $ context ) ? $ context : $ this -> getConfig ( 'update[context]' , self :: CONTEXT_UPDATE ) ; $ model = $ this -> controller -> formFindModelObject ( $ recordId ) ; $ this -> initForm ( $ model ) ; $ this -> controller -> formBeforeSave ( $ model ) ; $ this -> controller -> formBeforeUpdate ( $ 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 -> formAfterUpdate ( $ model ) ; Flash :: success ( $ this -> getLang ( "{$this->context}[flashSave]" , 'backend::lang.form.update_success' ) ) ; if ( $ redirect = $ this -> makeRedirect ( 'update' , $ model ) ) { return $ redirect ; } }
AJAX handler "onSave" called from the update action and
primarily used for updating existing records.

This handler will invoke the unique controller overrides
`formBeforeUpdate` and `formAfterUpdate`.

@param int $recordId Record identifier
@param string $context Form context
@return mixed
AJAX handler onSave called from the update action and primarily used for updating existing records .