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, 4 months ago
Updated 15 June 2024, 13 days 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.69.0 2024