AdvancedCustomFields/acf

BUG: get_fields function

Opened this issue · 3 comments

Hello,

I've discovered a problem with the "get_fields" function. Basically, I use Gutenberg and ACF Pro with Wordplate as a bridge to create blocks via the "acf_register_block_type" function. I also use sage 10 for the theme with Bedrock. But that's just the context, I don't think that's what's causing the bug.

The bug is that when I do get_fields(), for example get_fields(1295), the function returns "false" whereas if I do the same process but with get_field(), for example get_field('duration', 1295), I get the value that is stored in the database "1 day".

I've noticed that by entering the following code :

if (!$field) {
            $field = acf_get_valid_field(
                array(
                    name' => $key,
                    key' => '',
                    type' => '',
                )
            );
        }

line 300 of the api-template.php file, this solved my problem. In fact, in the get_field function, when I can't find my field in the store or in the database, we create a valid field by default using the key passed, whereas in the get_fields function, we don't do this.

Do you have any suggestions? Is it normal for this not to work? Or was it an oversight during development?

Thanks in advance.

Hi there,

Unfortunately this sounds like a known bug/limitation with the get_fields() function. We have an issue raised for this on our internal issue tracker and will be looking into a fix for a future release.

Hi,

In fact, I've just realised that the front-end field identifiers don't match those in the back-end. For example, I have a key that is equal to "field_a7e8bb83" on the front, whereas on the back I have "field_0778560d"...

The problem is that my data is present in the back, but not in the front. I need to update the post so that it updates the field key on the front.

How are the field keys generated and why does my wordpress distinguish between front and back?

Best regards

Hello @mattgrshaw

Is this still an ongoing issue?

I am still facing the same issue when I use this function in Gutenberg