Reputation: 3417
I'm using autoform with simple schema and collection2 and I've created a schema with subfields. I'm having trouble accessing the subfields in my template. I seem to just get [object object]. The subfields are arrays. Can someone tell me what I'm missing.
Path: template.html
{{#with currentUser}}
{{#with profile}}
{{#each CV}}
{{languages}}
{{/each}}
{{/with}}
{{/with}}
Path: schema.js
Schema.Language = new SimpleSchema({
language: {
type: String,
optional: true
},
proficiency: {
type: String,
optional: true
}
});
Schema.CV = new SimpleSchema({
languages: {
type: [Schema.Language],
optional: true
}
});
Schema.UserProfile = new SimpleSchema({
CV: {
type: Schema.CV,
optional: true,
},
});
Schema.User = new SimpleSchema({
profile: {
type: Schema.UserProfile,
optional: true
}
});
Upvotes: 2
Views: 89
Reputation: 4049
Schema.Language
has several properties, which means it's an object. Try this:
{{#with currentUser}}
{{#with profile}}
{{#each CV}}
{{#each languages}}
{{language}}
{{/each}}
{{/each}}
{{/with}}
{{/with}}
You also could replace the #each CV
with a #with
operator, as CV is not an array in your schema.
Upvotes: 1