When using the Single Date Time Picker Widget, I cannot find a way to remove a date value after one has been selected. Other widgets like Datetime Range Widget has an X to remove the date or time.

Is this possible with Single Date Time?

Using

  • drupal 8.6.7
  • datetime_range 8.6.7
  • single_datetime 8.x-1.7
  • xdan/datetimepicker library 2.5.20

Comments

waverate created an issue. See original summary.

askibinski’s picture

Version: 8.x-1.7 » 8.x-1.x-dev
Category: Support request » Feature request

Well, it looks like the library has an option for this using allowBlank.
See also https://xdsoft.net/jqplugins/datetimepicker/#allowBlank
https://github.com/xdan/datetimepicker/issues/256

Changing this to feature request since it is not possible with current implementation.

askibinski’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new4.47 KB

Here is patch which does 2 things:

  • Adds an option "allow blank" which allows the field to be empty even if the option validateOnBlur is true (which it is by default)
  • If this option is set, the onfocus blur() is disabled so a user can actually delete the input value
theodorosploumis’s picture

I confirm it works with Drupal 8.7.1.

waverate’s picture

Issue summary: View changes
waverate’s picture

Patch at #3 works great. Thank you @askibinski.

waverate’s picture

Component: Documentation » Code
Status: Needs review » Reviewed & tested by the community
aadesh.verma’s picture

I have tried this patch with Drupal version 8.7.3. Its working fine for me.

  • valic committed beaffea on 8.x-1.x authored by askibinski
    Issue #3027627 by askibinski, waverate: Delete Datetime Value
    
valic’s picture

Status: Reviewed & tested by the community » Fixed

Tnx, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.