I am using autoform + simple schema to generate a form field like this…
collections/ingredients.js
Ingredients.attachSchema(new SimpleSchema({
...
category: {
type: String,
label: "Category",
optional: true,
},
...
}));
client/ingredients/ingredients.html
...
{{> afQuickField name='category' options=ingredientsCatsOptions}}
...
client/ingredients/ingredients.js
Template.updateIngredient.helpers({
ingredientsCatsOptions: function() {
return ingredientsCats.find({}, {fields: {ingredientCatName: 1}}).map(function (c){
return {label: c.ingredientCatName, value: c._id};
});
}
});
This is all working fine however, my categories can be parent categories or subcategories and I would like the drop down selection to represent the tree structure of the categories.
Doing what’s suggested here works to generate a drop down selection showing the nested categories but I am unsure how to generate it from autoform instead of using a template.
I guess what I am asking is how can I replace this…
{{> afQuickField name='category' options=ingredientsCatsOptions}}
with this…
<select id="category" name="category" class="category">
<option value="">--Select--</option>
{{#each get_categories}}
<option value="{{_id}}">{{name}}</option>
{{/each}}
</select>
and still have it work properly with autoform?
Thanks