Problem/Motivation
An error occurs if the time is missing from an all-day event.
Steps to reproduce
Create a node type with a date field that has a time component and the option to choose "All day".
Add a node of this content type:
- For the date value clear the time component and choose "All day"
When you save you will get a message like
The value input for field Event Date Start date is invalid:
The value 04/12/2022 does not match the expected format.
Proposed resolution
Initially I tried fixing this in date_all_day_value() as suggested by the comments, but this is called too late in the process.
Then I tried adding an implementation of hook_element_info_alter in date_all_day.module to change the #value_callback for date_popup:
$type['date_popup']['#value_callback'] = 'date_all_day_popup_element_value_callback';
The new function date_all_day_popup_element_value_callback() would deal with the missing time. But then I saw date_popup_element_value_callback() is called from two other places, and I would end up needing to do a lot of modification to date_all_day.module.
So now I am thinking it may make sense to check if date_all_day is enabled in date_popup_element_value_callback() (and date_select_element_value_callback(), etc) and set a time value if needed.
Remaining tasks
Edit each of the widget element value call backs to check if date_all_day is active and set a time value if needed.
User interface changes
None
API changes
None
Data model changes
None
Comments