【发布时间】:2015-03-29 15:13:44
【问题描述】:
我将autoform 用于流星。我有一组嵌套模式,如下所示:
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
所以...是的。这就是我新鲜想法的极限。你有什么?
【问题讨论】:
-
在您发布此问题几天后,update-pushArray 类型似乎存在问题。根据 aldeed,您需要运行 Autoform 5.0.2 和 Meteor 1.0.3.1 或更高版本才能运行。 github.com/aldeed/meteor-autoform/issues/788。此外,aldeed 发布了一个可能对 autoform.meteor.com/updatepush 有帮助的示例
-
@BrianShamblen 将其作为答案发布?