pods
pods copied to clipboard
DateTime: Fix empty dates
Description
This PR makes sure React allows empty dates if the user allowed it in the field settings.
Related GitHub issue(s)
Fixes #6912
Changelog text for these changes
PR checklist
- [ ] I have tested my own code to confirm it works as I intended.
- [ ] My code follows the WordPress Coding Standards.
- [ ] My code follows the WordPress Inline Documentation Standards.
- [ ] My code includes automated tests for PHP and/or JS (if applicable).
@sc0ttkclark
Please review this PR thoroughly since it changes the way we store empty dates.
Currently we always store a date, even if empty (0000-00-00
etc). With this PR this changes. We still allow storage of such empty dates but by default it will simply store an empty string.
This will improve compatibility with third party tools for empty checks while AFAIK it will also be backwards compatible since we check for an empty string as well in PodsField_DateTime::is_empty()
- Added use of Pods\Whatsit\Pod class.
- Changed the way empty values are handled for datetime fields in table-based pods to match how they're handled in meta-based pods (empty string instead of 0000-00-00 00:00:00).
- Fixed a bug where an invalid date would be saved as '0000' when using HTML5 input type="datetime". This was caused by not passing allowEmpty flag to dateTimeValidator().