Search code examples
meteormeteor-blazemeteor-autoformsimple-schema

Unable to get autoform 6.0 to populate with existing data


I've updated to simple-schema npm and installed autoform 6.0 however I seem unable to successfully generate forms for collections. I get this error Exception in template helper: TypeError: Cannot read property 'mergedSchema' of undefined and I have no idea what it is referring to since this is a new build so it shouldn't be referencing any old autoform or simple-schema packages.

Path: 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>

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

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

Solution

  • Make sure you are also using aldeed:collection2-core and have attached your schema to your collection. For example...

    Books.attachSchema(Schemas.Book);