I have one "Ads" collection in mongoDB, and too many schema in following format:
AdsBaseSchema = new SimpleSchema({
_parentId: {
type: String,
optional: true
},
title: {
type: String,
label: "Title",
max: 200
}
description: {
type: String,
label: "Description",
optional: true
}
});
but they are different is some fields.
and I want to use them for insert autoform. like this:
{{> quickForm schema="AdsBaseSchema" id="insBaseAds" type="method" meteormethod="insBaseAds"}}
with this method:
insBaseAds: function(doc) {
Ads.insert(doc);
this.unblock();
}
This approach works correctly! But this is my question:
Its hard for me to use this approach for all of my schema! (as I told because I have too many schema)
I want to ask you:
Is this possible for meteor to use something like below autoform, and use just one autoform (form generator) for all schema?
{{> quickForm collection="Ads" schema="AdsBaseSchema" id="insertAds" type="insert"}}
Is it possible using both of "collection" and "schema" attribute in autoform??
I find a solutio for this issue:
I could try writing a helper for my template which returns a schema name dynamically, like so:
{{> quickForm collection="Ads" schema=schema id="insertAds" type="insert"}}
helper:
Template['myTemplate'].helpers({
schema() {
//Write your logic here
return "adsBaseSchema";
}
})
and fortunately it worked.