Hi folks,
I’m trying to build an app that will have posts with “expiry dates”, meaning after 30-60-90 days, it will be removed (or disappear).
I’m using simple-schema, collection2, and autoform of course.
In my schema I’m attempting the following method -
expiryDate: {
type: Date,
optional: true,
autoform: {
type: “select-radio”,
options: function() {
return [{
label: “1 Month ($35/month)”,
value: moment().add(30, ‘days’).toDate()
}, {
label: “1 Month ($35/month)”,
value: moment().add(60, ‘days’).toDate()
}, {
label: “1 Month ($35/month)”,
value: moment().add(90, ‘days’).toDate()
}];
}
}
},
And on page load, well, the page doesn’t load, and in the JS console I get the following error -
Meteor does not currently support objects other than ObjectID as ids
Also get this error underneath :
Uncaught TypeError: Cannot read property ‘removeEmptyStrings’ of undefined
In my template I reference the field like this :
{{> afFormGroup name="expiryDate" type="select-radio"}}
Any ideas for this?
I posted a similar question on stackoverflow but couldn’t get a full answer in the end.
Thanks!
Edit -
Switched some stuff around, instead using template.insert.helpers to add the select options into the select list
Template.insertListingForm.helpers({
expiryOptions: function() {
return [{
label: “1 Month ($35/month)”,
value: moment().add(30, ‘days’).toDate()
}, {
label: “2 Months ($30/month)”,
value: moment().add(60, ‘days’).toDate()
}, {
label: “3 Months ($25/month)”,
value: moment().add(90, ‘days’).toDate()
}];
}
});
Now in the JS console I get this error -
Uncaught Error: Unexpected object in htmljs in toText: Wed Apr 13 2016 19:59:27 GMT-0400 (EDT)
Which shows me that Moment is working properly, but still the page doesn’t display.
Thanks again!
GOT IT :
In simple schema, type as Date.
In select options
value: moment().add(30, ‘days’).toDate().toISOString()