【发布时间】:2016-07-06 20:45:20
【问题描述】:
我在同时显示一组更新表单时收到此控制台消息。据我所知,我已经正确地遵循了 Autoform 示例。谁能告诉我我做错了什么?
SimpleSchema.clean:过滤掉会影响键“_id”的值,这是架构不允许的
路径:form.html
{{#each student}}
{{#autoForm id=makeUniqueID type="update" collection="StudentHistory" doc=this}}
<div class="panel panel-default edit-profile-margin-pannel">
<div class="panel-body">
{{> afQuickField name='class'}}
</div>
</div>
{{/autoForm}}
{{/each}}
路径:form.js
Template.form.helpers({
student: function() {
return StudentHistory.find({});
},
makeUniqueID: function () {
return "update-each-" + this._id;
}
});
路径:Schema.js
StudentHistory = new Mongo.Collection("studentHistory");
StudentHistory.allow({
insert: function(userId, doc) {
return !!userId;
},
update: function(userId, doc) {
return !!userId;
},
remove: function(userId, doc) {
return !!userId;
}
});
var Schemas = {};
Schemas.StudentHistory = new SimpleSchema({
studentUserId: {
type: String,
autoValue: function() {
return this.userId;
},
autoform: {
type: "hidden"
}
},
class: {
type: String,
optional: false
}
});
StudentHistory.attachSchema(Schemas.StudentHistory);
【问题讨论】:
-
请显示
StudentHistory集合的架构代码。 -
我已经更新了上面的代码
标签: meteor meteor-autoform meteor-collection2