Meteor Autoform pushArray具有嵌套架构



我正在为流星使用自动变形。我有一组嵌套模式,如下所示:

addresses: {
  type: [Schemas.address],
  optional: true,
  defaultValue: []
}

我正在尝试使用update-pushArray 向数组添加地址

{{> quickForm id="myformid" type="update-pushArray" doc=getDocument collection=getCollection scope="addresses"}}

但我得到了这些宝石:

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]"

所以我试着用formToDoc钩子把它包装成一个数组:

SimpleSchema.clean: filtered out value that would have affected key "0", which is not allowed by the schema

所以。。。是 啊这是我新想法的极限。你有什么?

在您发布此问题几天后,更新pushArray类型似乎出现了问题。根据aldeed的说法,你需要运行Autoform 5.0.2和Meteor 1.0.3.1或更高版本才能工作。http://github.com/aldeed/meteor-autoform/issues/788.此外,Alded发布了一个可能有帮助的样本http://autoform.meteor.com/updatepush

最新更新