corcel / acf

Advanced Custom Fields (ACF) plugin for Corcel
128 stars 100 forks source link

BasicField doesn't facilitate the ability to return an empty value #4

Closed cjke closed 7 years ago

cjke commented 7 years ago

The second part of this line: https://github.com/corcel/acf/blob/master/src/Field/BasicField.php#L67 doesn't allow the field value to be empty.

In other words, an empty (yet set) field is trying to evaluate the following:

if (isset($postMeta->meta_value) and $postMeta->meta_value) { if (true and "") { if (true and false) {

I'll submit a PR, just trying to figure out the best way to stub out the mysql dump without needing to boot up an entire environment.

dsudzy commented 7 years ago

I am also experiencing a similar issue. dd(empty($page->acf->template)) equates to true and dd(isset($page->acf->template)) equates to false even though template is a string value. I found this online describing the problem and solution http://stackoverflow.com/questions/2045791/php-empty-on-get-accessor. It looks like it has to do with template being called as a magic method.

cjke commented 7 years ago

I am working on a PR atm for this. Should be done in the next day or two I think