monim67 / django-bootstrap-datepicker-plus

Bootstrap3/Bootstrap4/Bootstrap5 DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput with date-range-picker functionality for django >= 2.0
https://pypi.python.org/pypi/django-bootstrap-datepicker-plus
MIT License
223 stars 61 forks source link

javascript fails to set the hidden value when the remove icon is clicked #86

Closed daveisagit closed 1 year ago

daveisagit commented 1 year ago

Describe the bug Script should allow for a null date value

To Reproduce Steps to reproduce the behaviour: You can reproduce this on your demo pages

  1. Enable a date input picker with the remove icon
  2. Use the remove icon and the hidden value is not nulled out, and so the form action uses the last value entered.

datepicker-widget.js:119 Uncaught TypeError: e.date.format is not a function at HTMLDivElement. (datepicker-widget.js:119:41) at HTMLDivElement.dispatch (jquery-3.5.1.min.js:2:43090) at v.handle (jquery-3.5.1.min.js:2:41074) at Object.trigger (jquery-3.5.1.min.js:2:71513) at HTMLDivElement. (jquery-3.5.1.min.js:2:72108) at Function.each (jquery-3.5.1.min.js:2:2976) at S.fn.init.each (jquery-3.5.1.min.js:2:1454) at S.fn.init.trigger (jquery-3.5.1.min.js:2:72084) at h (bootstrap-datetimepicker.min.js:1:7860) at g (bootstrap-datetimepicker.min.js:1:13676)

Expected behaviour The field should be represented with a None value

on line 119 e.date will be null in this case hiddenInputElement.value = e.date.format(config.backend_date_format);

daveisagit commented 1 year ago

Thanks, quick turn around 👍

monim67 commented 1 year ago

Thanks for your detailed PR, the issue was addressed swiftly. Fixed in 5.0.2.