【发布时间】:2015-04-06 22:08:20
【问题描述】:
我尝试使用自动表单创建用户个人资料页面,但自动表单告诉我“错误:自动表单:当表单类型为插入时,您必须指定一个集合。”
我只有一种方法吗?
请帮我解决问题。
帮手Template.accountForm.helpers({
userSchema: function () {
return Schema.User;
}
});
模板<template name="accountForm">
<div class="panel-body">
{{#autoForm schema=userSchema collection=Users id="accountForm" type="insert"}}
<fieldset>
{{> afObjectField name='profile'}}
</fieldset>
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
</div>
</template>
架构
Schema = {};
Schema.UserProfile = new SimpleSchema({
lastname: {
type: String
}
});
Schema.User = new SimpleSchema({
_id: {
type: String,
regEx: SimpleSchema.RegEx.Id
},
email: {
type: String,
regEx: SimpleSchema.RegEx.Email
},
createdAt: {
type: Date
},
profile: {
type: Schema.UserProfile,
},
services: {
type: Object,
optional: true,
blackbox: false
}
});
Meteor.users.attachSchema(Schema.User);
【问题讨论】:
-
将您的自动表单标签更改为使用
type="update"。那应该可以解决它。 -
Tnx 回答但不,不工作
-
是的,再次出现“错误:AutoForm:当表单类型为插入时,您必须指定一个集合。”
标签: meteor