我正在使用 autoForm 生成表单。我有一个使用 simpl-schema 包设置的模式。当我单击表单上的提交时,什么也没有发生。我没有收到错误消息,并且我的数据库中没有新条目。该模式似乎正在工作,因为如果输入错误,则字符最小约束会显示在表单上。
我对 autoForm 将提交路由到哪个方法感到困惑。据我了解,它应该自动执行此操作,并且我不需要创建事件侦听器来处理提交。
我的代码如下
食谱.html
<template name="insertRecipeForm">
{{> quickForm collection="Recipes" id="insertRecipeForm" type="insert"}}
</template>
食谱.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)
我的 recipe.js 文件中有一个旧的“recipes.insert”方法。这会干扰 autoForm 吗?