Get postId for comments in autoform


#1

I am inserting comments using

{{> quickForm collection=“Comments” id=“insertCommentForm” type=“insert”}}

Schemas.Comments = new SimpleSchema({
  text: {
    type: String
  },
  postId : {
    type: String,
    autoform: {
      afFieldInput: {
        type: "hidden"
      }
    }
  }
});

My question is how to get postId automatically?


#2

Have a look at callback hooks. Get the id inside the hook and modify the document before saving.


#3

Thanks @rafael . Got it working.