Range mode doesn't work with Form API

Created on 6 August 2025, 9 days ago

Problem/Motivation

A flatpickr field can be added to a custom form by adding a form element like:

    $form['date_range'] = [
      '#type' => 'datetime_flatpickr',
      '#mode' => 'range',
      '#dateFormat' => 'Y-m-d',
      '#altInput' => TRUE,
      '#altFormat' => 'd M, Y',
      '#attributes' => [
        'class' => ['flatpickr-input'],
        'placeholder' => $this->t('Select the dates'),
      ],
    ];

However, the range mode is ignored and the default single mode is applied to the field.

Proposed resolution

Support the range mode in DateTimeFlatPickrWidgetTrait

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇪🇸Spain Peacog

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024