Add settings to disable dates in flatpickr webform field

Created on 29 January 2025, 2 months ago

Problem/Motivation

Currently, there is no way to disable specific dates on the webform flatpickr field without writing custom code or creating a custom module. This limits the flexibility for site builders and form creators who need to restrict date selection based on business rules or other requirements.

Steps to reproduce

  • Install and enable the Datetime Flatpickr module.
  • Create a new webform or edit an existing one.
  • Add a Flatpickr date element to the form.
  • Observe that there is no built-in option to disable specific dates, just days of the week (Mondays, Tuesdays,...)

Proposed resolution

Add a new setting to the Flatpickr Date element in webforms that allows users to specify dates to be disabled. This setting will be a textarea where users can enter dates (one per line). These dates will then be passed to the Flatpickr library to disable them in the date picker.

Remaining tasks

User interface changes

Add a new "Disable Dates" textarea field in the Flatpickr settings section of the Date element configuration form. The textarea will allow users to enter dates to be disabled, one per line.

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇧🇬Bulgaria mnakov

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mnakov
  • 🇭🇺Hungary nagy.balint

    Thank you!

    I think that we should implement this in a more generic way.

    The new option could be in DateTimeFlatPickrWidgetTrait.php

    And that could work in the widget settings as well as in the Element, and in the better exposed filters widget.

    Then all settings could be made available in the webform similarly to how it was done in the better exposed filter widget (FlatpickrDateBef.php)

  • 🇧🇬Bulgaria mnakov

    @nagy.balint, you are right. I'm uploading and updated patch to serve my current needs and will investigate a more generic way, as you say when I have more time. The patch is updated with date format validation. Removed the native dates of the week management as they use backend validation, but I need js validation without submission of the form. Added new way of disabling the days of the week.

Production build 0.71.5 2024