Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACFIntegration: Empty Datepickerfield returns "" instead of null #2940

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

rubas
Copy link
Contributor

@rubas rubas commented Mar 1, 2024

Problem

If you have an empty DatePicker field in ACF:

  • $post->raw_meta('empty_date_field') returns null
  • $post->meta('empty_date_field') returns ""

Solution

We return null, if !$value instead of $value.

Alternative

Maybe it's more in the spirit of the ACF to return false, but 😕
null though allows you to chain easily $post->meta('empty_date_field')?->format('d. F Y').

Return `null` on an empty date picker field
@coveralls
Copy link

Coverage Status

coverage: 87.937%. remained the same
when pulling 334fdd6 on rubas:patch-2
into 02ba68e on timber:2.x.

@gchtr
Copy link
Member

gchtr commented Mar 1, 2024

A note for when we look at this more closely:

We made a change in #2904 to not change return values in meta to null, because it could lead to problems if we over-optimize. The failing tests were on of these problems.

It could very well be that with the change in #2904, the result for raw_meta() and meta() doesn’t look different for date fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants