Meteor schema simple schema array must have defaultValue none
I have a form for people to create an event that will have members later, although not at creation time. When the event is created, no members should be added, so no member field is displayed in autoform:
createEvent.jade
template(name="createEvent")
+quickForm(collection="Events" id="createEventForm" type="insert" fields="name,description,location")
In order to submit the form, I believe I have to make sure that all the required fields of the collection Events
are valid, even if it is not a form. The form will not be submitted (the Submit button has no effect, I check minimongol to make sure there is no post entry), although I tried to add a 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 by setting the default event maker with no form field and now it works:
host: {
type: String,
label: "Host",
autoValue: function() {
return this.userId;
},
},
But I cannot get this default array. I've tried defaultValue: "['']"
several others as well. Stuck for now, please help ..
source to share
If you want the creator to be added as a default member, you can use this:
crew: {
type: [String],
label: "Crew",
autoValue: function() {
if( this.isInsert ) {
return [ this.userId ]
}
}
}
If you want to put an empty array by default try:
crew: {
type: [String],
label: "Crew",
defaultValue: [],
minCount: 0
}
source to share