I am using autoForm to generate a form. I have a schema set up using the simpl-schema package. When I click submit on my form nothing happens. I don't get an error message and there is no new entry to my database. The schema appears to be working because the character minimum constraints display on the form if something is entered wrong.
I am confused at which method autoForm routes the submit to. From what I understand it should automatically do it and I don't need to create an event listener to handle the submit.
My code is below
recipe.html
<template name="insertRecipeForm">
{{> quickForm collection="Recipes" id="insertRecipeForm" type="insert"}}
</template>
recipe.js
export const Recipes = new Mongo.Collection('recipes');
const Schemas = {};
Schemas.Recipe = new SimpleSchema({
name: {
type: String,
min: 1},
instructions: {
type: String,
min: 5,
autoform: {
afFieldInput: {
type: "textarea",
rows: 2,
class: "foo"
}
}
},
owner: {
type: String,
min: 1,
autoform: {
type: "hidden"
}
},
username: {
type: String,
min: 1,
autoform: {
type: "hidden"
}
}},
{ tracker: Tracker })
Recipes.attachSchema(Schemas.Recipe)
I have an old 'recipes.insert' method in my recipe.js file. Does this interfere with autoForm?
The
inserttype only inserts on the client side. If you want to pass the values to the meteor method you need to settype="method" meteormethod="recipes.insert"Alternatively you can user
type="normal"and intercept thesubmitevent to use your custom submission:see: https://github.com/Meteor-Community-Packages/meteor-autoform#non-collection-forms