diff --git a/frontend/client/src/controllers/record.js b/frontend/client/src/controllers/record.js index 4494a9e5d5..86bcbb3360 100644 --- a/frontend/client/src/controllers/record.js +++ b/frontend/client/src/controllers/record.js @@ -145,6 +145,11 @@ Espo.define('Controllers.Record', 'Controller', function (Dep) { this.showLoadingNotification(); model.once('sync', function () { + + if (options.attributes) { + model.set(options.attributes) + } + this.main(this.getViewName('edit'), { scope: this.name, model: model, diff --git a/frontend/client/src/views/modals/edit.js b/frontend/client/src/views/modals/edit.js index 80753e549b..904e242e59 100644 --- a/frontend/client/src/views/modals/edit.js +++ b/frontend/client/src/views/modals/edit.js @@ -83,11 +83,11 @@ Espo.define('Views.Modals.Edit', 'Views.Modal', function (Dep) { var router = this.getRouter(); if (!this.id) { url = '#' + this.scope + '/create'; - var attributes = this.getView('edit').fetch(); - - var model = this.getView('edit').model; - attributes = _.extend(_.clone(model.attributes), attributes); + var attributes = this.getView('edit').fetch(); + var model = this.getView('edit').model; + attributes = _.extend(attributes, model.getClonedAttributes()); + setTimeout(function () { router.dispatch(this.scope, 'create', { attributes: attributes, @@ -97,9 +97,15 @@ Espo.define('Views.Modals.Edit', 'Views.Modal', function (Dep) { router.navigate(url, {trigger: false}); }.bind(this), 10); } else { - url = '#' + this.scope + '/edit/' + this.id; + url = '#' + this.scope + '/edit/' + this.id; + + var attributes = this.getView('edit').fetch(); + var model = this.getView('edit').model; + attributes = _.extend(attributes, model.getClonedAttributes()); + setTimeout(function () { router.dispatch(this.scope, 'edit', { + attributes: attributes, returnUrl: Backbone.history.fragment, id: this.id });