I am trying to create a select dropdown list with two groups using either select2 or selectize. Using the following in my schema (not using select2 or selectize), it works as it should. However, when I include the type: "select2"
I get a bunch of errors about duplicate ids, and if I use type: "selectize"
only the second group (Boring Years) works.
JS
"recipeIngredients.$.ingredient": {
type: String,
label: "Ingredient/Recipe",
optional: true,
autoform: {
//type: "select2",
//type: "selectize",
options: function () {
var results = [];
var currentUserId = Meteor.userId();
var mapResults = function(category) {
results.push({label: category.ingredientName, value: category._id});
};
_.each( Ingredients.find({createdBy: currentUserId}).fetch(), function(doc) {
mapResults(doc);
});
return [
{
optgroup: "Fun Years",
options: results
},
{
optgroup: "Boring Years",
options: [
{label: "2011", value: 2011},
{label: "2010", value: 2010},
{label: "2009", value: 2009}
]
}
];
}
}
},