1

Please accept my apologies if this has been asked, I'm sure it has and I'm equally sure it's something minor I'm missing, not understanding correctly.

I've running the following locally https://autoform.meteorapp.com/updateaf

I'm specifically using the updateaf form... and have all packages necessary installed i.e. accounts-passwords, accounts-ui and accounts-base.

My question is how can I show user specific data for the fields firstname, last name and age within this interface?

Currently all I get is every submission no matter whom I am logged in as.

Marshall G
  • 11
  • 1

1 Answers1

0

I don't have any experience with updateaf in particular, but I have done a lot with Meteor.

I assume that you are wanting to only display the currently-logged-in user's information and allow them to update it?

If so, I think you would want to have a publication that only publishes the current user's info (using Meteor.userId(), and you would likely have to link the People object's ._id to the Meteor userId), and then have that data automatically selected.

Changed parts from the Javascript section on the link you provided (https://autoform.meteorapp.com/updateaf):

Original (Only showing pertaining stuff that deals with selectedPersonId, rest is all on the link):

Meteor.publish(null, function () {
  return People.find();
});

Template.updateaf.helpers({
  selectedPersonDoc() {
    return People.findOne(Session.get("selectedPersonId"));
  },
  isSelectedPerson() {
    return Session.equals("selectedPersonId", this._id);
  }
});

Template.updateaf.events({
  'click .person-row'() {
    Session.set("selectedPersonId", this._id);
  }
});

Change to (Rather than displaying all users and allowing them to change by clicking, just return the single one that corresponds to the Meteor User) (You might have to change/remove some other js functions to get rid of the "People List"):

Meteor.publish(null, function () {
  return People.findOne({ _id: Meteor.userId() );
});

Template.updateaf.helpers({
  selectedPersonDoc() {
    return People.findOne({ _id: Meteor.userId() );
  }
});

Please let me know if you have any questions, I hope this helps.

Some additional tutorials if you want: https://guide.meteor.com/data-loading.html https://themeteorchef.com/tutorials/publication-and-subscription-patterns