Insert and update autoform


#1

Im using autoform and building an app where I have a client and have a workout for them. I have it now with autoform so that it will autosave the current document but I would like to be able to insert a new workout and select a date and fill out the form with info from that date instead of always just updating the current workout. How do I set the doc of the form so it filled in the stuff related to that date and client.


#2

You can pass a doc parameter to populate fields

Template.newWorkout.helpers({
  workoutPrefill: function() {
    return {
      punchedInAt: new Date(), // or any date you'd like
      clientId: Meteor.userId(), // the user is the client
      workoutType: 'weights' // some workout detail
    };
  }
});
<template name="newWorkout">
  {{> quickForm collection="workouts" doc=workoutPrefill id="newWorkoutForm" type="insert"}}
</template>