I have a form for people to create an event that will later have members, though not at time of creation. When the event is created, no members should be added, so the autoform shows no member field:
createEvent.jade
template(name="createEvent")
+quickForm(collection="Events" id="createEventForm" type="insert" fields="name,description,location")
For the form to submit, I believe I must ensure all required fields of the Events
collection have a value, even if that's not by the form. The form will not submit (Submit button has no effect, I'm checking minimongol to ensure there is no record entry) even though I have tried adding defaultValue:
crew: {
type: [String],
label: "Crew",
defaultValue: ""
},
and autoValue where the creator is added as a member:
crew: {
type: [String],
label: "Crew",
autoValue: function() {
return this.userId;
},
},
I had this problem a minute ago setting the event creator by default without a form field and it now works:
host: {
type: String,
label: "Host",
autoValue: function() {
return this.userId;
},
},
But I can't get this array based default going. I also tried defaultValue: "['']"
and a few others. Stuck for now, please help..
If you'd like the creator to be added as the default member, you can use this:
crew: {
type: [String],
label: "Crew",
autoValue: function() {
if( this.isInsert ) {
return [ this.userId ]
}
}
}
If you want to insert an empty array by default, try:
crew: {
type: [String],
label: "Crew",
defaultValue: [],
minCount: 0
}