So I have the following keys in my SimpleSchema:
"profile.otherLocations": {
type: Array,
label: "Other Locations",
autoform: {
afFieldInput: {
type: "other-location-select",
multiple: "multiple",
companySelectId: "employeeProfileEditCompanySelect",
filterBy: "otherLocations"
}
}
},
"profile.otherLocations.$": {
type: String,
label: "Id",
},
Based on the above, the template will create the “Other Locations” section on the page, but inside of that, a textfield is rendered for each element in the array returned from the database (which is expected, since it is an array of Strings). However, if I try and remove the autoform:{…} that is in the top-level field, and put it into the array element field, I was able to write some client-side JS in the autorun() to manually set the first field so it looks like this:
where the first multiselect is what I want (all array elements represented in a single “multiple” dropdown), but it insists on creating multiselects for each of the elements in the array. So if the profile.otherLocations array in mongoDB has a length of 12, it will create 11 additional empty selects like you see above. I just want all array elements (strings) to be represented in one multiselect field.
What would be the best way to prevent the additional select fields from being created? Alternately, is there any easier way to do this using ‘select2’? Have been stuck on this for almost a week, could definitely use advice.