InvalidArgumentException: The date cannot be created from a format. in Drupal\Component\Datetime\DateTimePlus::createFromFormat() (line 253 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Created on 12 March 2024, 8 months ago
Updated 15 June 2024, 5 months ago

We are translating an entity which uses the datetime_range_separate_inputs_flatpickr widget for a date range. This daterange itself is not translatable, and therefore the widget is hidden when translating.
When you save the translated entity, the following error occurs. InvalidArgumentException: The date cannot be created from a format. in Drupal\Component\Datetime\DateTimePlus::createFromFormat() (line 253 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).

This error happens in the validation because the date values are not in the correct format and the DrupalDateTime::createFromFormat function fails.

Checking if the field widget access property is TRUE in same conditional where you check if the field has a values, solves this issue.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇧🇪Belgium kensae

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