【问题标题】:Unable to get autoform 6.0 to populate with existing data无法让 autoform 6.0 填充现有数据
【发布时间】:2017-07-25 17:10:52
【问题描述】:

我已经更新到 simple-schema npm 并安装了 autoform 6.0,但是我似乎无法成功地为集合生成表单。我收到此错误Exception in template helper: TypeError: Cannot read property 'mergedSchema' of undefined,我不知道它指的是什么,因为这是一个新版本,所以它不应该引用任何旧的 autoform 或 simple-schema 包。

路径: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});
});

【问题讨论】:

  • {{&gt; quickForm collection=Profile id="updateProfile" type="update"}}collection=Profile 大写 P 并且模板助手中的方法 profile() 使用小写 p 可以吗?
  • 另一件事是您需要确保您在客户端代码中导入imports/ui/pages/candidate-registration/contact-information/contact-information.js,而不是.html 文件。否则,模板代码将不会运行,并且帮助程序 Profile 将无法用于集合属性中的自动表单。

标签: meteor meteor-blaze meteor-autoform simple-schema


【解决方案1】:

确保您也在使用aldeed:collection2-core 并拥有attached your schema to your collection。比如……

Books.attachSchema(Schemas.Book);

【讨论】:

    猜你喜欢
    • 2015-01-18
    • 1970-01-01
    • 1970-01-01
    • 2013-12-01
    • 2012-09-28
    • 1970-01-01
    • 2012-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多