You should find the answer in aldeed:collection-2 where it talks about attaching multiple schemas to a collection.
Here is a very simple example
Schemas = {};
BaseSchema = {
type: {
type: String,
allowedValues: ['simple','variant'],
autoform: {
type: 'hidden'
}
},
title: {
type: String,
label: "Title",
max: 200
},
};
Schemas.Simple = new SimpleSchema(_.extend(BaseSchema,
{
simpleField: {
type: Date,
label: "Simple Date",
},
}
));
Schemas.Variant = new SimpleSchema(_.extend(BaseSchema,
{
variantField: {
type: Date,
label: "Variant Date",
},
}
));
Collection.attachSchema( Schemas.Simple, {selector: {type: 'simple'}} );
Collection.attachSchema( Schemas.Variant, {selector: {type: 'variant'}} );
Then you can use autoform like this
<template name="collectionInsert">
{{>quickForm collection=Collection doc=doc id="insertPageForm" type="insert"}}
</template>
And you provide doc via a helper
Session.setDefault('type','simple');
Template.collectionInsert.helpers({
doc(){
// all autoform needs is the type so it can decide which schema to use
return { type: Session.get('type') }
}
});