I’am making a simple form to create recipes using this three packages and I have found a issue. I achieved to fix them but I think my solution is not the better way to fix it.
The issue come when a try to submit a form which has two hidden form field which are required. They are put with autoValue.
I had fixed it changing the restriction required to optional. This is the code:
Recipes = new Mongo.Collection('recipes');
recipeSchema = new SimpleSchema({
name: {
type: String,
label: "Name"
},
author: {
type: String,
label: "Author",
autoValue: function() {
return this.userId;
},
autoform: {
type: "hidden"
}
},
createdAt: {
type: Date,
label: "Created At",
autoValue: function() {
return new Date();
},
autoform: {
type: "hidden"
}
}
});
Recipes.attachSchema(recipeSchema);
Recipes.methods = {};
Recipes.methods.newRecipe = new ValidatedMethod({
name: 'Recipes.methods.newRecipe',
validate: recipeSchema.validator(),
run(){
}
});
<template name="createRecipe">
{{> quickForm collection="Recipes" id="insertRecipeForm" type="method" meteormethod="Recipes.methods.insert"}}
</template>
I think that I could create another schema to validate but I would like to know your opinion.