我嘗試使用autoform創建用戶配置文件頁面,但autorofm告訴我「錯誤:AutoForm:當表單類型插入時,您必須指定一個集合。」Autoform用戶配置文件頁面
我只有一種方法通過方法?
請幫我解決問題。
助手
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」'。這應該解決它。 – 2015-04-05 16:02:14
Tnx爲答案,但不,不工作 – jmlv 2015-04-05 20:23:30
仍然同樣的錯誤? – 2015-04-05 22:04:14