Skip to content

Commit b5bb938

Browse files
committed
properly set values coming in on edit forms
1 parent b146143 commit b5bb938

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
aldeed:autoform@4.0.0
2-
aldeed:autoform-bs-datetimepicker@1.0.3
2+
aldeed:autoform-bs-datetimepicker@1.0.4
33
aldeed:simple-schema@1.1.0
44
base64@1.0.2
55
blaze@2.0.4

autoform-bs-datetimepicker.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
AutoForm.addInputType("bootstrap-datetimepicker", {
22
template: "afBootstrapDateTimePicker",
3+
valueIn: function (val, atts) {
4+
// datetimepicker expects the date to represent local time,
5+
// so we need to adjust it if there's a timezoneId specified
6+
var timezoneId = atts.timezoneId;
7+
if (typeof timezoneId === "string") {
8+
if (typeof moment.tz !== "function") {
9+
throw new Error("If you specify a timezoneId, make sure that you've added a moment-timezone package to your app");
10+
}
11+
if (val instanceof Date) {
12+
return moment(AutoForm.Utility.dateToNormalizedLocalDateAndTimeString(val, timezoneId), "YYYY-MM-DD[T]HH:mm:ss.SSS").toDate();
13+
}
14+
}
15+
16+
return val;
17+
},
318
valueOut: function () {
419
var m = this.data("DateTimePicker").getDate();
520

package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package.describe({
22
name: 'aldeed:autoform-bs-datetimepicker',
33
summary: 'Custom bootstrap-datetimepicker input type with timezone support for AutoForm',
4-
version: '1.0.3',
4+
version: '1.0.4',
55
git: 'https://github.com/aldeed/meteor-autoform-bs-datetimepicker.git'
66
});
77

0 commit comments

Comments
 (0)