Skip to content

Commit

Permalink
Fix D9.4 deprecation but also REQUIREMENT
Browse files Browse the repository at this point in the history
Like c'mon Drupal people, you deprecate but super require/enforce and add the fix AFTER the callback C'MON (MAD!)
  • Loading branch information
DiegoPino committed Aug 10, 2022
1 parent d3a8123 commit afc0d2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Element/WebformMetadataDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ public static function processWebformMetadataDate(&$element, FormStateInterface

$element['date_from']['#datepicker'] = TRUE;
$element['date_to']['#datepicker'] = TRUE;
// @see https://www.drupal.org/node/3258267
// Basically the preRender callback that should fix this is called AFTER the
// \Drupal\Core\Render\Element\Date::processDate.
// So stupid. No where people check if an array key exists before using it
// NOWHERE!!
$element['date_from']['#attributes']['type'] = 'date';
$element['date_to']['#attributes']['type'] = 'date';

$element['date_free']['#title'] = $date_free_title;
$element['date_free']['#attributes']['class'][] = 'webform-date-free';
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/WebformElement/WebformMetadataDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public function prepare(
// Convert date element into textfield with date picker.
if (!empty($element['#datepicker'])) {
$element['#attributes']['type'] = 'text';

// Must manually set 'data-drupal-date-format' to trigger date picker.
// @see \Drupal\Core\Render\Element\Date::processDate

$element['#attributes']['data-drupal-date-format'] = [$element['#date_date_format']];
}

Expand Down

0 comments on commit afc0d2b

Please sign in to comment.