Meteor-Community-Packages / meteor-autoform-bs-datepicker

Custom "bootstrap-datepicker" input type for AutoForm
MIT License
25 stars 32 forks source link

Date picker doesn't unset value when input is cleared and value is updated #24

Closed hartwoolery closed 7 years ago

hartwoolery commented 9 years ago

When I log the modifier before submit should show {$unset:{my_date_field:""}} but just ignores the field, retaining the previous value.

lgollut commented 9 years ago

+1 here.

This bug seems to be located in the valueOut function of the bootstrap-datepicker input type definition in autoform-bs-datepicker.js.

There's a check here on this.val() so the function return only if field value is not falsy. Here is the actual function

valueOut: function () {
  if (this.val()) {
    var val = this.datepicker('getUTCDate');
    return (val instanceof Date) ? val : this.val();
  }
}

Obviously, an empty string will never call the return statement. I changed it to

valueOut: function () {
  var val;
  if (this.val()) {
    val = this.datepicker('getUTCDate');
  }
  return (val instanceof Date) ? val : this.val();
}

to return an empty string when needed.

egoldblum commented 8 years ago

+1 ran into this same bug. @aldeed can you merge and release #27?

alexcorre commented 8 years ago

+1 @aldeed

jykae commented 7 years ago

@aldeed We also have the same issue with datepicker, when is the fix going to be merged & released?