How to subscribe to auxCollection, or specific subscription, on 'add new' form?
I have a collection with a relationship field.When the 'create new' form for the collection renders, I want to provide a user select box containing the entity names from the referenced collection. However, the dropdown box does not populate when autopublish is disabled.
adminConfig.js
AdminConfig.js contains the correct collection in auxCollections.
Residents: {
icon: "users",
color: "red",
auxCollections: ['Homes'],
tableColumns: [
{label: "First name", name: "firstName"},
{label: "Last Initial", name: "lastInitial"}
],
extraFields: ['homeId']
},
Schema
The schema has an autoform options function that returns options for the select widget.
homeId: {
type: String,
label: 'Home',
autoform: {
options: function() {
// Get all homes from related collection
}
}
}
Screenshot

Hi, I had the same issue. Look at this thread in order to solve it (under "temporary solution"): https://github.com/yogiben/meteor-admin/issues/124 David
Alright, I notice your router code looks like this:
Router.waitOn(function(){
console.log('----------ROUTER waitOn subscriptions for admin'); // this is to verify in the console that this function is actually called > you can delete it after it's working
return Meteor.subscribe('posts') // put here the subscription to all documents
}, {
only: ['adminDashboard'] // this is the name of the yogiben:admin route
});
Routes may not be ideal for subscription management, e.g. when not using Iron Router. How can we hook in to the `template...created, in order to subscribe at the template level?
If we do use routes, how do I hook in to a specific route? E.g. admin/Houses/add. Is there a way to handle this with a template level subscription?
routes updated in readme https://github.com/yogiben/meteor-admin#custom-route-options
AdminConfig = {
// ...
collections: {
Posts: {
routes: {
new: {
waitOn: function () { return Meteor.subscribe('images'); }
},
view: {
waitOn: function () { return Meteor.subscribe('images'); }
},
edit: {
waitOn: function () { return Meteor.subscribe('images'); }
}
}
}
}
// ...
}
@HazemKhaled thanks for your response :-)
@HazemKhaled how would you accomplish this for User's UserProfiles section?