我正在使用accounts-ui登录系统。我想创建一个我使用autoform显示的配置文件表单。当我尝试提交表单时,params在URL中传递,页面刷新但没有任何内容保存到集合中。
有什么想法吗?
这是我的架构(我也试过使用UserProfile架构但是没有用)
Schema = {};
Schema.UserProfile = new SimpleSchema({
firstName: {
type: String,
regEx: /^[a-zA-Z-]{2,25}$/
},
lastName: {
type: String,
regEx: /^[a-zA-Z]{2,25}$/
},
gender: {
type: String,
allowedValues: ['Male', 'Female']
},
bio: {
type: String,
},
avatar: {
type: String,
},
pinCode: {
type: Number,
min: 7,
max: 7
},
phoneNumber: {
type: Number,
min: 9,
max: 10
}
});
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);
Template.signupForm.helpers({
users: function () {
return Meteor.users;
},
userSchema: function () {
return Schema.User;
}
});
/* as an idea ....
Template.signupForm.editingDoc = function () {
return Meteor.users.find({_id: Meteor.userId()});
};
*/
//template
<template name="signupForm">
<div class="panel-body">
{{#autoForm schema=userSchema id="signupForm" doc=editingDoc type="update"}}
<fieldset>
{{> afObjectField name='profile'}}
</fieldset>
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
</div>
</template>
答案 0 :(得分:3)
现在已经很晚了,但是如果有人需要这个,你遇到的问题就是你从来没有给过用户集合:
{{#autoForm
collection='Meteor.users' //this was your issue
id="signupForm"
doc=editingDoc
type="update"
}}
如果您愿意,您甚至可以将表单限制为仅包含以下内容的配置文件:
{{#autoForm
collection='Meteor.users'
schema="Schema.UserProfile" //both collection & schema will render schema
id="signupForm"
doc=editingDoc
type="update"
}}