Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions distribution.amd/backbone-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2019,18 +2019,20 @@ Form.editors.NestedModel = Form.editors.Object.extend({
//Get the constructor for creating the nested form; i.e. the same constructor as used by the parent form
var NestedForm = this.form.constructor;

var data = this.value || {},
var self = this,
data = this.value || {},
key = this.key,
nestedModel = this.schema.model;

//Wrap the data in a model if it isn't already a model instance
var modelInstance = (data.constructor === nestedModel) ? data : new nestedModel(data);

this.nestedForm = new NestedForm({
model: modelInstance,
idPrefix: this.id + '_',
fieldTemplate: 'nestedField'
var attrs = {model: modelInstance, idPrefix: this.id + '_'};
// Pass fields down to the NestedForm
_.each(['template', 'templateData', 'fields'], function(key) {
if (self.schema[key]) attrs[key] = self.schema[key];
});
this.nestedForm = new NestedForm(attrs);

this._observeFormEvents();

Expand Down
2 changes: 1 addition & 1 deletion distribution.amd/backbone-forms.min.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions distribution/backbone-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2032,18 +2032,20 @@ Form.editors.NestedModel = Form.editors.Object.extend({
//Get the constructor for creating the nested form; i.e. the same constructor as used by the parent form
var NestedForm = this.form.constructor;

var data = this.value || {},
var self = this,
data = this.value || {},
key = this.key,
nestedModel = this.schema.model;

//Wrap the data in a model if it isn't already a model instance
var modelInstance = (data.constructor === nestedModel) ? data : new nestedModel(data);

this.nestedForm = new NestedForm({
model: modelInstance,
idPrefix: this.id + '_',
fieldTemplate: 'nestedField'
var attrs = {model: modelInstance, idPrefix: this.id + '_'};
// Pass fields down to the NestedForm
_.each(['template', 'templateData', 'fields'], function(key) {
if (self.schema[key]) attrs[key] = self.schema[key];
});
this.nestedForm = new NestedForm(attrs);

this._observeFormEvents();

Expand Down
2 changes: 1 addition & 1 deletion distribution/backbone-forms.min.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/editors/nestedmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ Form.editors.NestedModel = Form.editors.Object.extend({
//Get the constructor for creating the nested form; i.e. the same constructor as used by the parent form
var NestedForm = this.form.constructor;

var data = this.value || {},
var self = this,
data = this.value || {},
key = this.key,
nestedModel = this.schema.model;

//Wrap the data in a model if it isn't already a model instance
var modelInstance = (data.constructor === nestedModel) ? data : new nestedModel(data);

this.nestedForm = new NestedForm({
model: modelInstance,
idPrefix: this.id + '_',
fieldTemplate: 'nestedField'
var attrs = {model: modelInstance, idPrefix: this.id + '_'};
// Pass fields down to the NestedForm
_.each(['template', 'templateData', 'fields'], function(key) {
if (self.schema[key]) attrs[key] = self.schema[key];
});
this.nestedForm = new NestedForm(attrs);

this._observeFormEvents();

Expand Down