2

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});
});
bp123
  • 3,217
  • 8
  • 35
  • 74
  • 1
    Is it okay that you have `{{> quickForm collection=Profile id="updateProfile" type="update"}}` collection=Profile with capital `P` and the method profile() in the template helpers has a lowecase `p`? – tiomno Sep 03 '17 at 04:26
  • 1
    Another thing is that you need to be sure that you're that you're importing `imports/ui/pages/candidate-registration/contact-information/contact-information.js` in your client code and not the `.html` file. Otherwise, the Template code won't run and the helper `Profile` won't be available for the autoform in the collection attribute. – tiomno Sep 03 '17 at 05:21

1 Answers1

1

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

Books.attachSchema(Schemas.Book);
jordanwillis
  • 10,449
  • 1
  • 37
  • 42