Datepicker plugin gives Undefined array key "type"

Created on 14 June 2024, 4 months ago
Updated 29 August 2024, about 2 months ago

We are using BEF 6.0.6 Datepicker plugin on a date filter with Drupal 9.5.11 and we got this warning in watchdog:

Warning : Undefined array key "type" dans Drupal\Core\Render\Element\Date::processDate() (.../Drupal/Core/Render/Element/Date.php ligne 71) 

Here is the method missing the 'type' key:

  public static function processDate(&$element, FormStateInterface $form_state, &$complete_form) {
    @trigger_error('Drupal\Core\Render\Element\Date::processDate() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3258267', E_USER_DEPRECATED);
    // Attach JS support for the date field, if we can determine which date
    // format should be used.
    if ($element['#attributes']['type'] == 'date' && !empty($element['#date_date_format'])) {
      $element['#attached']['library'][] = 'core/drupal.date';
      $element['#attributes']['data-drupal-date-format'] = [$element['#date_date_format']];
    }
    return $element;
  }

I don't think I have any core patch altering this method and no other module using it. While investigatiing I have found out that warning disapear when not using the datepicker from BEF. So I noticed that in the Datepickers.php file, just adding ['#attributes']['type'] = 'date'; to all elements solved my problem but I am not sure if this is the way to go or if it is really a BEF issue.
Anyone is having the same problem?

πŸ› Bug report
Status

Closed: duplicate

Version

7.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium davidiio

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

Comments & Activities

  • Issue created by @davidiio
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Are you able to test 7.0.x on D10?

  • Status changed to Postponed: needs info 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Or provide more detailed steps

  • πŸ‡§πŸ‡ͺBelgium davidiio

    I can't upgrade this website to D10 right now. We're stuck with 9.5.11 and so we can't use BEF 7 version. I could try it on other sites but here I would like it to work on D9.5.11 and BEF 6.0.6. Downgrading to BEF 6.0.5 made it work though.

    We have a view of node filtered by a date field (not the created date) we enabled BEF and selected the datepicker widget for this exposed date filter and got the warning I mentioned, there is nothing else I could say about this issue. When I don't use the datepicker filter is working.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    6.0.6 is where jquery was replaced. But the snippet supplied shows a function that is now removed in D10 so this may be a non issue going forward.

  • Status changed to Closed: duplicate about 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Seems to be a dup. That one has an MR so closing this one.

Production build 0.71.5 2024