2017-03-05 22 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

回答