Problem/Motivation

I would like to be able to disable specific dates in the jquery ui date picker.
It is already possible to disable specific days of the week. but not a list of arbitrary dates.

Proposed resolution

Update webform_jqueryui_datepicker.element.js to support a data-disabled-dates attribute.

Comments

dahousecat created an issue. See original summary.

dahousecat’s picture

dahousecat’s picture

Status: Active » Needs review
dahousecat’s picture

Example data-disabled-dates attribute:

data-disabled-dates="2024-12-17,2024-12-18,2024-12-19,2024-12-25,2024-12-26"

jrockowitz’s picture

StatusFileSize
new814 bytes

I would not want to support individual options; instead, I'd like to make it easier for people (aka developers) to define custom options to a webform element.

Attached is a POC (untested) approach that adds support to data-options="{}" the data-options would always be applied last. This could become a universal solution that allows developers to define element-specific custom JS options.

The approach you could take would be something like...

data-options="{'beforeShowDay': my_custom_before_show_data'}"

function. my_custom_before_show_data(date) {
   // Ideally, you could pull the dates from the input's 'data-disabled-dates.'
    const dates = ['2024-12-17', '2024-12-18' , '2024-12-19' ];

    const formatted = date.toISOString().split('T')[0]
    return [!dates.includes(formatted)];
};

New features will only be added to 6.3.x

dahousecat’s picture

I think that approach sounds very wise.
The patch I have will solve my use case for now, but once this feature gets added I can delete my patch :)

dahousecat’s picture

Status: Needs review » Closed (won't fix)
jrockowitz’s picture

Let's leave this open because I think #5 needs to happen for most webform element libraries.

cilefen’s picture

Status: Closed (won't fix) » Needs review
liam morland’s picture

Version: 6.2.8 » 6.3.x-dev
jrockowitz’s picture