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.
What is the logic behind defaulting to REQUEST_TIME for empty date fields?
if ($type == 'date') {
$date = !empty($data['date']) ? $data['date'] : REQUEST_TIME;
I have an optional deadline field for which i use a token to display the date. If the deadline isn't set, i don't want the current date to be displayed. I just want it to be empty (or not be replaced so i can remove it after).
As it is now, there is no way to distinguish between an empty field and a filled one.
Comments
Comment #1
jeastham CreditAttribution: jeastham commentedThis becomes a real problem when exporting fields in modules like Fill PDF. If date fields are left blank, the token returns the current date, making it difficult to have optional date fields.
Comment #2
Dave ReidThis is because we have to match the core behavior. See the system_tokens() function in core. Unfortunately since this bug was not able to be fixed prior to 7.0 release, I don't think we can fix it until Drupal 8 with #943028: 'Date' token namespace is ambiguous