corcel / corcel/acf

DateTime fields are returning current date when field is empty

Open
#77 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
132
Forks
102
PR merge metrics
No merged PRs in 30d

Description

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,

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.