I'm using date fields for customers who want to select a delivery date.

I'm trying to disable specific dates from the date picker, so that for example it's not possible to choose our holy Sunday.

Is there a way to configure the date field so that specific dates can be selected en other dates are set to unavailable (disabled)?

Current situation

original datepicker

Disabling a specific day

better date picker

Desired situation

best date picker field

Any idea if I can make this with the current date module?
All ideas are welcome !!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

svhooydonck’s picture

Hi! Did you find a way?

Jawi’s picture

Did not find a sollution jet. Al help is very welcome!

sHaDoW_LiGhT’s picture

Jawi’s picture

Thanks for mentioning the work calendar.

It does the trick for 50%.

Now I have to figure out how to plan the availability for a whole year.

Jawi’s picture

Issue summary: View changes

spelling

bmateus’s picture

I've been searching for something similar, and I've found the Date Restrictions module. https://drupal.org/project/date_restrictions

Maybe it can help.

hockey2112’s picture

Issue summary: View changes

Any update on this? I am looking for the same functionality. I investigated the Date Restrictions module, but have not found a way to exclude specific dates (or to allow front-end users to select a date).

nithinkolekar’s picture

views as source and negate..?
just a concept..
If we have some content type having date field which marks it as holidays/scheduled days then we can create a view of that content type which outputs the datefield values (just like entityreference display) and after that we can negate the value to get the selectable dates.

update: corrected small typo

nithinkolekar’s picture

just found https://www.drupal.org/project/date_restrictions by jonhattan and he mentioned in its todo list :)

Jawi’s picture

Title: exclude dates from picker » Date restriction

Thank you Nithin for pointing me in the wright direction. Going to work on my case this week.

kurti’s picture

Latest news? Date restrictions can´t restrict individual dates or individual intervals...

Work calendar only restricts weekdays in whole year.

Is there other module which restricts weekdays and individual dates?

Kir Lazur’s picture

Hi, I had such problem and found simple solution. You can apply it for date_popup.js in makeFocusHandler function. array with dates can be written to Drupal.settings and it's will be available in js code. In PHP , $availability is array of dates with states, for example.
This needs work, but the general direction is clear.
It's a snippet.

var array = ["2016-03-01","2016-03-02","2016-03-03","2016-03-10","2016-03-11"];

$(this).datepicker({
            beforeShowDay: function (date) {
          if($.inArray($.datepicker.formatDate('yy-mm-dd', date ), array) > -1) {
                  return [false,"","Booked out"];
              } else {
                  return [true,'',"available"];
              }
 });
drupal_add_js(array(
        'datePopup' => array(
          'CalendarAvailability' => array(
              'cvid' => $calendar['cid'],
              $availability,
          )
        ),
      ), array('type' => 'setting'));