I'm trying to use an autoform to update an array object within a collection. The collection contains lots of information however with this form I only want to update the careerHistory. I would like to be able to control the layout of the form using bootstrap columns. To do this I need to be able to reference careerHistory.$.company
and careerHistory.$.title
independently. Currently, I'm only able to render the form by referencing name="careerHistory"
. Whenever I try to reference the specific field within the array the form doesn't print.
Path: Profile.js
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
import { addressSchema } from '../../sharedSchemas/addressSchema.js';
SimpleSchema.extendOptions(['autoform']);
export const Profile = new Mongo.Collection('Profile');
Profile.allow({
insert: function(userId, doc) {
return !!userId;
},
update: function(userId, doc) {
return !!userId;
},
remove: function(userId, doc) {
return !!userId;
}
});
Schemas.Profile = new SimpleSchema({
userId: {
type: String,
optional: true
},
'careerHistory.$': Object,
'careerHistory.$.company': {
type: String,
optional: false,
},
'careerHistory.$.title': {
type: String,
optional: true,
});
Profile.attachSchema(Schemas.Profile);
Path: Profile.html
{{#autoForm collection=profileCollection doc=profile id="candidateCareerHistory" type="update"}}
{{> afArrayField name="careerHistory"}}
{{/autoForm}}
Path: Profile.js
profile() {
return Profile.findOne({userId: Meteor.userId()});
},
profileCollection() {
return Profile;
}