I'd like to build an autoform in meteor that presents user with a twelve radio buttons and records an entry for each of the 12 buttons. I can get the form working easily enough if I create 12 different buttons—see below, but I'm wondering if it is possible to create an array to do this a bit more easily.
Homework = new Mongo.Collection("homework");
Homework.attachSchema(new SimpleSchema({
userId:{
type: String,
autoValue:function(){return this.userId},
},
userName:{
type: String,
autoValue:function(){return Meteor.users.findOne({_id: this.userId}).emails[0].address},
},
fName:{
type: String,
autoValue:function(){return Meteor.users.findOne({_id: this.userId}).profile.fName},
},
lName:{
type: String,
autoValue:function(){return Meteor.users.findOne({_id: this.userId}).profile.lName},
},
page: {
type: Number,
label: "Page Number",
max: 200
},
problem1: {
type: Boolean,
},
problem2: {
type: Boolean,
},
problem3: {
type: Boolean,
},
problem4: {
type: Boolean,
},
problem5: {
type: Boolean,
},
problem6: {
type: Boolean,
},
problem7: {
type: Boolean,
},
problem8: {
type: Boolean,
},
problem9: {
type: Boolean,
},
problem10: {
type: Boolean,
},
problem11: {
type: Boolean,
},
problem12: {
type: Boolean,
},
}));
Yup! You can simple define arrays in SimpleSchema using this notation:
And in your template