Browse files

In NestedModels, allow serializing data out of nested sub-models by c…

…alling data.toJSON on them if it's a defined method.
  • Loading branch information...
1 parent 924abe8 commit eba574491ab660c8fcaffc5e06ff4db08454745e @theinterned committed Mar 19, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/backbone-forms.js
View
5 src/backbone-forms.js
@@ -1384,7 +1384,10 @@
key = this.key,
nestedModel = this.schema.model,
nestedModelSchema = (nestedModel).prototype.schema;
-
+
+ if(_(data.toJSON).isFunction()) {
+ data = data.toJSON();
+ }
this.form = new Form({
schema: nestedModelSchema,
model: new nestedModel(data),

0 comments on commit eba5744

Please sign in to comment.