[regression] datetime_timestamp widget does not use default field value

Created on 16 January 2024, 12 months ago
Updated 15 March 2024, 10 months ago

Problem/Motivation

The datetime_timestamp field widget does not respect the field's default value or default value callback. Instead, the entity form's date + time widgets are left empty and the current time is saved to the field if one is not provided.

This change was introduced in 10.2.1 in πŸ› Remove sample date from date field error message and title attribute Fixed with a check in TimestampDatetimeWidget::formElement() to only use the field item delta value if the entity is "not new": https://git.drupalcode.org/project/drupal/-/commit/5404ebfb11155b53dee0e...

Steps to reproduce

  1. Add a timestamp field eg: timestamp_test, to an entity.
  2. Set a default value for the timestamp_test field, eg: 01/01/2024 - 12:00:00 AM
  3. Configure the entity form display to use the datetime_timestamp "Datetime Timestamp" widget.
  4. Go to create a new entity. Observe that that the timestamp_test field does not use the configured default value.
  5. Save the entity. Observe that the current time is saved to the timestamp_test field.

Proposed resolution

Do not check if the entity is new. Instead use the previous logic: If a field item delta value is set, use it to create a new drupal date time object.

Remaining tasks

.

Review

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

datetime_timestamp widget is fixed to respect field default values.

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
FieldΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States paul121 Spokane, WA

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