Search code examples
javascripttwitter-bootstrapmeteordatetimepickermeteor-autoform

How to fix 'dtp.setDate' error in Meteor AutoForm datetimepicker?


I'm trying to use this AutoForm package, but as I was trying their own code this error came out.

TypeError: dtp.setDate is not a function
at null.<anonymous> (aldeed_autoform-bs-datetimepicker.js:141)
at view.js:199
at Function.Template._withTemplateInstanceFunc (template.js:457)
at view.js:197
at Object.Blaze._withCurrentView (view.js:538)
at viewAutorun (view.js:196)
at Tracker.Computation._compute (tracker.js:323)
at new Tracker.Computation (tracker.js:211)
at Object.Tracker.autorun (tracker.js:562)
at Blaze.View.autorun (view.js:209)

What I have is, a template just displaying the quick form:

<template name="test">
<h1>Autoform test</h1>
{{> quickForm collection="Tests" id="insertTest" type="insert"}}
</template>

With a simple schema test also:

Tests = new Mongo.Collection("tests");

TestsSchema = new SimpleSchema({
  typeTest: {
    type: Date,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "bootstrap-datetimepicker"
      }
    }
  }
});

Tests.attachSchema(TestsSchema);

I've followed the instructions given at this page, and added aldeed:autoform-bs-datetimepicker and tsega:bootstrap3-datetimepicker to my Meteor project.


Solution

  • This is a known issue in the 4.x.x release. You can fix this error by downgrading to version 3.1.3_3.

    To install the tsega:bootstrap3-datetimepicker package with version 3.1.3_3, run the following command:

    meteor add tsega:bootstrap3-datetimepicker@=3.1.3_3 
    

    You probably also want to install the twbs:bootstrap package in order to get full Bootstrap support.