In Date Field - cannot add days that are not allowed (like Sundays)

We use form for appointments and would like to restrict users to not request for appointments on weekends using the date field.

I've searched around, but couldn't find any suitable answer for drupal 8 webforms.

If there's a workaround, please do let me know.

Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

omdb created an issue. See original summary.

jrockowitz’s picture

You can create a Date element with a jQuery UI datepicker and add some JS to customize the calendar.

@https://stackoverflow.com/questions/2968414/disable-specific-days-of-the... @https://codepen.io/anon/pen/XmQrPY

jrockowitz’s picture

Status: Active » Closed (works as designed)
omdb’s picture

I created a Date element, selected "Use date picker"

Use date picker

I then added this on page load:

        $("#ui-datepicker-div").datepicker("destroy");
        $("#ui-datepicker-div").datepicker({
          beforeShowDay: function(date) {
            var day = date.getDay();
            return [(day != 0), ''];
          }
        });
        $("#ui-datepicker-div").datepicker("refresh");

But nothing happens.

If I run the code in console, the window updates and disables Sundays. But when I click out and click again, it is back to normal. Is there something I am missing here?

omdb’s picture

Status: Closed (works as designed) » Active

Changing status for visibility. Sorry if this breaks any rules.

jrockowitz’s picture

We can't support custom code in the Webform issue queue. If you need coding help, you should post your question to https://drupal.stackexchange.com/questions/tagged/webform

jrockowitz’s picture

Status: Active » Closed (won't fix)
Benaan’s picture

I've created a patch that makes this configurable.

jrockowitz’s picture

Status: Closed (won't fix) » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: disable-days-2901873-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jrockowitz’s picture

I am not ready to support this feature in the core webform module.

I think there needs to be a dedicated datepicker element that implements all the options available for the jQuery UI Datepicker. This element should be handled in a dedicated contrib module.

@see #2778335: Port to drupal 8

jrockowitz’s picture

Status: Needs work » Postponed
jrockowitz’s picture

Status: Postponed » Closed (won't fix)
webengr’s picture

Was this ever solved by a module or putting custom javascript in webform settings?