Reputation: 552
I made one form using autoForm & collection2 package in meteor. I want to add one dropdown field to that form which option is populate based on another collection i have. can i do that way?
Any advice...
Upvotes: 3
Views: 553
Reputation: 4703
You can use a template helper function to populate the options for the drop down. Define a function that returns an array of option objects, then set the options
attribute of the select field to the name of the function.
Template.appInsert.helpers({
getOptions: function() {
var cursor = YourCollection.find();
return cursor.map(function(doc) {
return {label: doc.name, value: doc._id};
});
}
});
Then use the helper function in your quick field definition:
{{>afQuickField name='fieldName' options=getOptions}}
Upvotes: 1