acf
acf copied to clipboard
DateTime fields are returning current date when field is empty
Hi,
First off all I would like to thank you for this cool package and the work you invested. While working with this package I noticed a problem that is affecting the DateTime fields.
When doing a call on a ACF DateTime field that is empty, the method returns a Carbon Object containing the current date. I think it would be better if the method returns false when the value for the requested field is empty.
The reason that the datePicker() method returns the current date and not false is because the methods assigns a value to the date with the following code:
$this->date = Carbon::createFromFormat($format, $dateString);
In the case the field is empty, $dateString will be empty and $this->date
will have the current date.
What do you think about this fix ? I will submit a PR and link in within this issue
Thank you,
I'm still facing this issue.
Quick fix: vendor/corcel/acf/src/Field/DateTime.php Line 28
$this->date = $dateString ? Carbon::createFromFormat($format, $dateString) : null;
has there been a fix for this? a function or snippet that returns null on empty date string?