-
Notifications
You must be signed in to change notification settings - Fork 33
CfsAutoForm.Hooks.beforeInsert() is called, but after my Meteor.call() to save the form #51
Comments
After repeatedly looking at this, I wanted to share my findings with everyone so that I might get some help. I started by putting breakpoints in the following places (I am using Chrome, if that matters):
I then modified my Meteor.methods({
createNewAssignment: function(doc) {
console.log('>>>> creating: ', doc);
// Clean the doc to make sure any autoValues are done
Assignments.simpleSchema().clean(doc);
// Check the schema
check(doc, Assignments.simpleSchema());
doc._id = Assignments.insert(doc);
//... do some other stuff
return doc;
}, Here are the chain of events that occur:
I am not sure why the form seems to submit more than once, and that might possibly be the cause of all of this. However, what I can tell is that the |
Ok, further information...it looks like the I am not sure why I saw issues with the timing. Best I can come up with is that my breakpoints might have caused the timing of the code to be off? |
I figured things out. You can't call Template.assignments.onRendered(function() {
AutoForm.hooks({
insertAssignmentsForm: {
before: {
method: CfsAutoForm.Hooks.beforeInsert
},
after: {
method: CfsAutoForm.Hooks.afterInsert
},
onError: function(formType, error) {
console.log('error: ', error);
},
onSuccess: function(formType, error) {
FlowRouter.go('/assignments/' + result.assignmentId);
}
}
});
}); When you do it the way I was prior using |
I am using the
method
form type with CFS AutoForm. When I submit my form, thebefore
hook is called, where I callCfsAutoForm.Hooks.beforeInsert()
, but the lines that actually set the saved fileIds to the doc are not called until after myMeteor.call()
executes and saves the doc. As a result, all my file uploads store the files, but the file ids are not properly set on the doc. I am providing my code below:Form hooks:
Form setup:
Versions:
Why is the before not finishing prior to the
Meteor.call()
call runs?The text was updated successfully, but these errors were encountered: