I'm using autoform for meteor. I have an array of nested schemas, like so:
addresses: {
type: [Schemas.address],
optional: true,
defaultValue: []
}
and I'm attempting to add an address to the array using update-pushArray
{{> quickForm id="myformid" type="update-pushArray" doc=getDocument collection=getCollection scope="addresses"}}
But I'm getting these gems:
MinimongoError: Cannot apply $push modifier to non-array
"MongoError: The field 'addresses' must be an array but is of type Object in document {_id: "383EfPJgeZQJFgs72"} [409]"
So I tried wrapping it in an array in a formToDoc
hook:
SimpleSchema.clean: filtered out value that would have affected key "0", which is not allowed by the schema
So... yeah. That's the limit of my fresh ideas. What do you have?
It looks like there was an issue with the update-pushArray type until a few days after you posted this question. According to aldeed you need to be running Autoform 5.0.2 and Meteor 1.0.3.1 or higher for it to work. http://github.com/aldeed/meteor-autoform/issues/788. Also, aldeed posted a sample that might help http://autoform.meteor.com/updatepush