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...
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}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With