2017-03-05 19 views
2

我已更新到simple-schema npm並安裝了autoform 6.0,但我似乎無法成功地爲集合生成表單。我得到這個錯誤Exception in template helper: TypeError: Cannot read property 'mergedSchema' of undefined,我不知道它指的是什麼,因爲這是一個新的構建,所以它不應該引用任何舊的autoform或simple-schema包。無法獲取autoform 6.0來填充現有數據

路徑:imports/ui/pages/candidate-registration/contact-information/contact-information.html

<template name="App_contactInformation"> 
    {{#with profile}} 
    {{firstName}} 
     {{> quickForm collection=Profile id="updateProfile" type="update"}} 
    {{/with}} 
    {{/if}} 
</template> 

路徑:imports/ui/pages/candidate-registration/contact-information/contact-information.js

import { Profile } from '/imports/api/profile/profile.js'; 
import './contact-information.html'; 

Template.App_contactInformation.onCreated(function() { 
    this.autorun(() => { 
    this.subscribe('private.profile'); 
    }); 
}); 

Template.App_contactInformation.helpers({ 
    profile() { 
    var user = Profile.findOne({userId: Meteor.userId()}); 
    return user; 
    } 
}); 

路徑:imports/api/profile/server/publications.js

// All profile-related publications 

import { Meteor } from 'meteor/meteor'; 
import { Profile } from '../profile.js'; 

Meteor.publish('private.profile', function() { 
    if (!this.userId) { 
    return this.ready(); 
    } 
    return Profile.find({"userId": this.userId}); 
}); 
+1

是不是好,你有'{{> quickForm集合=配置文件ID = 「updateProfile」 TYPE = 「更新」}}'集合=簡介與資本'P'和方法簡介()在模板助手中有一個小寫的'p'? – tiomno

+1

另一件事是,你需要確保你是在你的客戶端代碼中導入'imports/ui/pages/candidate-registration/contact-information/contact-information.js'而不是'.html '文件。否則,模板代碼將不會運行,輔助屬性'Profile'將不可用於collection屬性中的autoform。 – tiomno

回答