Problem

The timestamp field definition (TimestampItem) has the incorrect default widget specified which prevents forms from validating properly that use the field. The default widget specified is "datetime_default" but should be "datetime_timestamp". They both appear visually the same on the form, but the major difference is that "datetime_default" does not convert the date input into a unix timestamp value, so the range constraint that validates the proper timestamp value will always fail (because 2016-10-10T12:30:31 is not a proper number).

It can be resolved by simply re-saving the form display form, because the widget dropdown for the timestamp field has the proper "datetime_timestamp" value there and will save the proper widget value on this form submission.

The real resolution is to fix the field definition.

Steps to reproduce:

1. Add a "timestamp" field to an entity type, like the Article node type
2. Configure it with all defaults
3. Attempt to create an entity of that type, filling in a valid date.
4. Observe a form validation error "This value should be a valid number" (see screenshot)

Comments

bkosborne created an issue. See original summary.

bkosborne’s picture

EDIT: Found the root cause and updated the issue summary

bkosborne’s picture

Title: Range constraint on timestamp fields always fails » Timestamp field definition has wrong default widget, causing form validation errors on forms that use the field
Issue summary: View changes
bkosborne’s picture

Status: Active » Needs review
StatusFileSize
new675 bytes

Here's a patch w/o tests, don't have time for tests at the moment

bkosborne’s picture

Issue summary: View changes

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

kristen pol’s picture