【发布时间】:2016-03-02 12:56:21
【问题描述】:
错误信息:
“未捕获的错误:过滤掉不在模式中的键后,您的修饰符现在为空”
在 Meteor 中将 autoform 与 collection2 和简单模式一起使用。 架构:
Injuries = new Mongo.Collection('injuries');
Rehab = new SimpleSchema({
exercise: {
type: String,
label: "Rehab Exercise"
},
sets: {
type: Number,
label: "Sets"
},
duration: {
type: Number,
label: "Set Duration (in Minutes)"
},
date: {
type: String,
label: "Date of Rehab Exercise"
},
rehabnotes: {
type: String,
label: "Notes: i.e. 70% Intensity During Sprints",
max: 200
},
injuryid:{
type: String,
}
});
Injuries.attachSchema(new SimpleSchema({
player: {
type: String,
label: "Player",
max: 50
},
injury: {
type: String,
label: "Injury"
},
notes: {
type: String,
label: "Notes",
max: 200
},
injurydate: {
type: Date,
label: "Date of Injury",
},
rehab: {
type: [Rehab],
optional: true
}
}));
以及模板中的表单代码:
{{#autoForm collection="Injuries" schema="Rehab" id="insertRehabForm" type="update"}}
<fieldset>
{{> afQuickField name='exercise' options=options}}
{{> afQuickField name='sets'}}
{{> afQuickField name='duration'}}
{{> afQuickField name='date'}}
{{> afQuickField name='rehabnotes' rows=6}}
</fieldset>
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
我可以使用主页上的自动表单很好地插入文档,在单个文档页面上使用此自定义表单我在提交时收到错误。
我在提交之前设置了一个集合挂钩,但这看起来只是一个架构错误,也许我在原始 Injuries 架构上设置的 Rehab 数组搞砸了?我为此所做的搜索都是关于架构中的“类型”参数与预期的不匹配,但我在这里检查了这些,它们看起来不错。有什么建议吗?
【问题讨论】:
标签: mongodb meteor simple-schema