Based on Miriam's answer, I would also like to share what I did to make everything work. Maybe this can be helpful.
Schemes → Actions
Schemas.actions = new SimpleSchema({ actions : { type : Array, optional: false, minCount: 1, autoform: { name: "actions" } }, "actions.$" : { type: Object }, "actions.$.action_type": { type : String, optional: false, label : "Action Type", autoform: { type : "select", class : "action_type form-control", name : "action_type", label : "Select type of action", options: function() { let returnValue = [ {label: "Action 1", value: "action_1"}, {label: "Action 2", value: "action_2"}, ]; return returnValue; } } }, "actions.$.action_1" : { type : Schemas.action1, minCount: 1, optional: true, label : "Action 1", } });
Schemes → action1
Schemas.action1 = new SimpleSchema({ "action1_to" : { type : String, optional: false, label : "Email To", autoform: { type : "text", label : "Email To", placeholder: "Comma seperated values...", class : "form-control" } }, "action1_cc" : { type : String, optional: true, label : "Email Cc", autoform: { type : "text", label : "Email Cc", placeholder: "Comma seperated values...", class : "form-control" } }, "action1_subject": { type : String, optional: false, label : "Subject", autoform: { type : "text", label : "Subject", placeholder: "Subject for the Email", class : "form-control" } }, "action1_body" : { type : String, optional: false, label : "Email Content", autoform: { label : "Email Content", rows : 6, class : "form-control auto-size", placeholder: "Email Content goes here...", style : "font-size: 120%;" } } });
Note that Schemas.action1 must be loaded before Schemas.actions else, you will only have a text field instead of a form
Patterns
<template name="actions"> {{#autoForm id="actions-form" doc=step.data schema=schema}} {{> afArrayField name="actions" template="actions" step=step}} {{> wizardButtons}} {{/autoForm}} </template> <template name="afArrayField_actions"> <div class="panel panel-default"> <div class="panel-heading">{{afFieldLabelText name=this.atts.name}}</div> {{#if afFieldIsInvalid name=this.atts.name}} <div class="panel-body has-error"> <span class="help-block">{{{afFieldMessage name=this.atts.name}}}</span> </div> {{/if}} <ul class="list-group"> {{#afEachArrayItem name=this.atts.name minCount=this.atts.minCount maxCount=this.atts.maxCount}} <li class="list-group-item autoform-array-item"> <div> <div class="autoform-remove-item-wrap"> {{#if afArrayFieldHasMoreThanMinimum name=../atts.name minCount=../atts.minCount maxCount=../atts.maxCount}} <button type="button" class="btn btn-primary autoform-remove-item"><span class="glyphicon glyphicon-minus"></span></button> {{/if}} </div> <div class="autoform-array-item-body"> {{> afQuickField name=this.current.action_type label=false options=actionOptions}} {{> UI.dynamic template=currentFieldValue data=this }} </div> </div> </li> {{/afEachArrayItem}} {{#if afArrayFieldHasLessThanMaximum name=this.atts.name minCount=this.atts.minCount maxCount=this.atts.maxCount}} <li class="list-group-item"> <button type="button" class="btn btn-primary autoform-add-item" data-autoform-field="{{this.atts.name}}" data-autoform-minCount="{{this.atts.minCount}}" data-autoform-maxCount="{{this.atts.maxCount}}"><span class="glyphicon glyphicon-plus"></span></button> </li> {{/if}} </ul> </div> </template> <template name="action_1"> {{> afQuickField name=this.current.action_1 }} </template>
You will see {{> wizardButtons}} in the template because I use the form-wizard package
and Template.registerHelper for the currentFieldValue helper
Template.registerHelper("currentFieldValue", function() { let val = AutoForm.getFieldValue(this.current.action_type, "actions-form"); return val || null; });
Hope this helps someone and saves time.
Thanks Mariam for this decision