2015-04-05 84 views
1

我嘗試使用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); 
+0

更改自動窗體標籤以使用'type =「update」'。這應該解決它。 – 2015-04-05 16:02:14

+0

Tnx爲答案,但不,不工作 – jmlv 2015-04-05 20:23:30

+0

仍然同樣的錯誤? – 2015-04-05 22:04:14

回答

2

你並不需要他lper函數,只需使用Meteor.users對象。

{{#autoForm collection='Meteor.users' doc=currentUser type='update' id='accountForm'}} 
    {{> afQuickField name='profile'}} 
<button type='submit' class="btn btn-primary">Save profile</button> 
{{/autoForm}} 
+1

這是工作!大tnx! – jmlv 2015-04-06 19:46:09

+0

不應該是'afObjectField'? – 2015-05-14 12:42:46

相關問題