Method not called with autoform when using method-update?


I’m struggling to get method-update working with autoform.

Template works fine with just method. However, I need to update it. It never calls the meteor method when attempting to update.
This works:

{{#autoForm doc=this collection="Courses" id="editCourse" type="method" meteormethod="insertCourse"}}

This doesn’t

{{#autoForm doc=this collection="Courses" id="editCourse" type="method-update" meteormethod="updateCourse"}}

Schema works, data loads up fine in the form. Schemas as added to the collection. Although not for all values of the document. Only the ones I want edited. Might this be an issue?

Methods used for testing(No security added as of yet. Gotta get them working first! :smile: )

updateCourse: function (doc, objID) {
    Courses.update(objID, {$set: doc})
insertCourse: function (doc) {


Any pointers are much appreciated!


method-update does not give you a new document when it is called, it gives you a modifier object. You do not need the $set in you update function since it is already a modifier object.

updateCourse: function (modifier, objID) {
    Courses.update(objID, modifier);

Though be careful doing updates this way, you have to make sure that the user has the right permissions since anyone cal call methods, they could supply someone else’s userId or a different modifier object.


Ahh. Thank you. Wondered why it was called modifier and not doc. However, in the debugger, the update method is never called. I tried setting a breakpoint on the update line, but it is never called.


The method is not called until modifier is valid on the client.

I’ve had this sort of issue before because I had a invalid data type (or a non optional data that wasn’t set) as per the schema but it doesn’t show me because I hid the field, (e.g created field)

autoform: {

So your client side will try to validate the form and fail silently and not show you the error. Had this happen twice and wasted hours on it.

Another possible cause (although it may sound stupid) is, make sure you’re breaking on your server, not chrome console… just in case.


That made a lot of sense. Was doing an autoform and had a required field in the schema. But after I removed that, it seems to act like a normal form. It submits the form and reloads the page with ?field=value&field=value etc etc.
Also changed to quickform to get things as standard as possible before I start messing with things.

{{> quickForm doc=this collection="Courses" id="edtCourse" type="method-update" meteormethod="updateCourse"}}

Insert seems to work with this method now. But changing to method-update and to the update meteormethod makes it act like a normal form.

Edit: Typo


Not sure what you mean by this, ‘normal’ as in it hits the server breakpoint as expected?
To test if you’ve got hidden invalid fields, just remove the hidden type on all your fields and submit.

Note, if you use yogiben:admin, this is also a common issue I come across, forgetting to set my hidden, required fields. Silent and deadly…


I found AutoForm.debug() which might help people! Mentioned briefly on their github

By normal I mean that it submits the form as if it was any other normal GET form. It navigates to the same URL with ?field=value&field=value etc etc.
However, adding a submit hook in the template rendered callback like the code below, I can preventDefault and call the meteor method manually.

editCourse: {
  onSubmit: function (insertDoc, updateDoc, currentDoc) {
    this.event.preventDefault();'updateCourse', currentDoc._id, updateDoc);

But this is what I suppose the method-update is supposed to do? Along with a client side check()


Ah ok I see what you mean now, um, no, that’s definitely not right. Your method-update should be making a through DDP in the background and there shouldn’t be any HTTP verb or changing of routes and you definitely shouldn’t have to put in a client side hook to manually do the on top of autoform’s method-update.


hi entropy,

I tried the code you post up there for the method-update,
it works but updating the wrong collection.

i want it to update the selected ID of my drop down box.

updateLesson: function (modifier,objID) {

colLearner.update(objID, modifier);

console.log(modifier) display

{ ‘$set’:
I20160331-15:10:19.201(2)? { cStudent: ‘L3Qrvo2ccRvR2bbbL’,
I20160331-15:10:19.202(2)? dtCertifiedDate: Wed Mar 09 2016 02:00:00 GMT+02
00 ( Standard Time),
I20160331-15:10:19.202(2)? cCertificationArchieved: ‘average’,
I20160331-15:10:19.203(2)? dtUpdatedAt: Thu Mar 31 2016 15:10:19 GMT+0200 (
Standard Time) } }

AND console.log(modifier) display
my parameter ID ‘hrykNpndQPZKbBg7t’

but in my situation i want to update
cStudent: ‘L3Qrvo2ccRvR2bbbL’.

not working with the code below…

colLearner.update(objID, cStudent);

Please help… over two days have been struggling with it!


how did u get that objID you updating there ? to me when i try to update using the same method i get this error message: I20160520-17:25:48.929(2)? Exception while invoking method ‘send’ TypeError
: Cannot read property ‘_id’ of undefined
here is my example code below

send: function (doc){
Event.update(doc._id, {$set: {doc}});


Hello mandla1,

for you to get the objID, your method type have to be method-update instead of using method only,
something like this

{{> quickForm doc=this collection=“Company” id=“companyId” type=“method-update” meteormethod=“callYourserverMethod”}}

and make sure you have the doc=this.

I hope that helps.