Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In Drupal 7 we implemented hook_node_validate()
to validate the scheduling fields when a node form is submitted. In Drupal 8 this should be done using validation constraints.
- If the 'unpublish on' field is filled in we should validate whether the entered date corresponds to the configured date format.
- If the validation fails, display the following error message:
The 'unpublish on' value does not match the expected format of %time
- Also remove the corresponding lines from
scheduler_node_validate()
.
See change record: Entity level validation constraints can be added and the documentation page for the Entity Validation API.
This is postponed on #2490570: Validate that the 'publish on' value matches the expected format.
Comments
Comment #1
jonathan1055 CreditAttribution: jonathan1055 commentedComment #2
jonathan1055 CreditAttribution: jonathan1055 commentedThe validation is no longer required now that the format is not configurable - see #2799869: Date field placeholder text doesn't reflect date format defined in admin settings - hardcode the format