src/Component/InlineEdit.php
public function setModel(\atk4\data\Model $model)
    {
        parent::setModel($model);
        $this->field = $this->field ? $this->field : $this->model->title_field;
        if ($this->autoSave && $this->model->loaded()) {
            if ($this->cb->triggered()) {
                $value = $_POST['value'] ? $_POST['value'] : null;
                $this->cb->set(function () use ($value) {
                    try {
                        $this->model[$this->field] = $this->app->ui_persistence->typecastLoadField($this->model->getElement($this->field), $value);
                        $this->model->save();

                        return $this->jsSuccess('Update successfully');
                    } catch (ValidationException $e) {
                        $this->app->terminate(json_encode([
                              'success'            => true,
                              'hasValidationError' => true,
                              'atkjs'              => $this->jsError(call_user_func($this->formatErrorMsg, $e, $value))->jsRender(),
                          ]));
                    }
                });
            }
        }

        return $this->model;
    }
public function setModel(\atk4\data\Model $model)
    {
        parent::setModel($model);
        $this->field = $this->field ? $this->field : $this->model->title_field;
        if ($this->autoSave && $this->model->loaded()) {
            if ($this->cb->triggered()) {
                $value = $_POST['value'] ? $_POST['value'] : null;
                $this->cb->set(function () use ($value) {
                    try {
                        $this->model[$this->field] = $this->app->ui_persistence->typecastLoadField($this->model->getElement($this->field), $value);
                        $this->model->save();

                        return $this->jsSuccess('Update successfully');
                    } catch (ValidationException $e) {
                        $this->app->terminate(json_encode([
                              'success'            => true,
                              'hasValidationError' => true,
                              'atkjs'              => $this->jsError(call_user_func($this->formatErrorMsg, $e, $value))->jsRender(),
                          ]));
                    }
                });
            }
        }

        return $this->model;
    }
public function setModel ( \ atk4 \ data \ Model $ model ) { parent :: setModel ( $ model ) ; $ this -> field = $ this -> field ? $ this -> field : $ this -> model -> title_field ; if ( $ this -> autoSave && $ this -> model -> loaded ( ) ) { if ( $ this -> cb -> triggered ( ) ) { $ value = $ _POST [ 'value' ] ? $ _POST [ 'value' ] : null ; $ this -> cb -> set ( function ( ) use ( $ value ) { try { $ this -> model [ $ this -> field ] = $ this -> app -> ui_persistence -> typecastLoadField ( $ this -> model -> getElement ( $ this -> field ) , $ value ) ; $ this -> model -> save ( ) ; return $ this -> jsSuccess ( 'Update successfully' ) ; } catch ( ValidationException $ e ) { $ this -> app -> terminate ( json_encode ( [ 'success' => true , 'hasValidationError' => true , 'atkjs' => $ this -> jsError ( call_user_func ( $ this -> formatErrorMsg , $ e , $ value ) ) -> jsRender ( ) , ] ) ) ; } } ) ; } } return $ this -> model ; }
Set Model of this View.

@param \atk4\data\Model $model

@return \atk4\data\Model
Set Model of this View .