meteor-autoform: Form doesn't submit

I’m not sure why, but the following form doesn’t submit:

<template name="customerItem">
{{#autoForm collection="Customers" id="customerItem" doc=updateItem type="update"}}
{{> afQuickField name='name'}}
<button type="submit" class="ui green submit button">Save</button>
{{/autoForm}}
</template>
AutoForm.addHooks('customerItem', {
  onSubmit: function (insertDoc, updateDoc, currentDoc) {
    console.log(arguments);
    return false;
  }
});

The input loads the correct data but clicking submit does nothing - no submission, no error, no onSubmit call. I think the reason is that no events were bound because the submit wasn’t detected. If this is the case I suspect adding a console.warn() may be useful so the developer knows something is missing. But it could be something else entirely. I can confirm that this works:

{{> quickForm collection="Customers" id="customerItem" type="update" doc=updateItem}}

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 3
  • Comments: 18 (11 by maintainers)

Most upvoted comments

If you had an onError hook for your form, it would be called with the “insert not allowed” error. You can set up a global hook to log all form errors while developing:

AutoForm.addHooks(null, {
    onError: function (name, error, template) {
      console.log(name + " error:", error);
    }
  });

This, combined with setting SimpleSchema.debug = true, can help a lot during development.

Did you try turning on debug (SimpleSchema.debug = true in client code)? Usually something like this is due to a required field not being included on the form, although that shouldn’t be a problem for an update form. In debug mode, any validation errors are logged to the console. Validation errors would cause submission to stop before onSubmit and before the update call, and they don’t call the onError callback.

Otherwise I will need a full reproduction of the issue in a cloneable repo to provide more help.