Home Forums Gutenberg ACF Blocks with a repeater field empty in Admin


ACF Blocks with a repeater field empty in Admin

  • This post is to help people encountering this bug. I found a fix for my case.

    I’m using :
    – Bedrock
    – ACF Pro 5.8
    – WordPress 5.1.1
    – Timber library 1.9.4

    Bug description : ACF Block with a repeater field inside, it works saving values and values can be displayed but the default ACF logic does not retrieve the values at all in the admin form. Which makes your repeater fields look empty.

    If you want more details about the bug origin in the code you can ask.

    So I added this piece of code in my functions.php file :

     * This filter is used to inject preview value.
     * Added params because there's no documentation for the "acf/pre_load_value" filter yet.
     * @param	$value (mixed) the value found in the database
     * @param	$post_id (mixed) the $post_id from which the value was loaded
     * @param	$field (array) the field array holding all the field options
     * @return	$value
    function wm_fix_repeater_gutenberg( $value, $post_id, $field )
    	// Conditional field type here because it's not available in the filter name
    	// For now I only saw a bug with repeater field
    	if ($field['type'] != 'repeater') return $value;
    	// We must preload the value before ACF checks it so we avoid the default ACF logic which breaks the value.
    	$value = acf_get_metadata( $post_id, $field['name'] );
    	return $value;
    add_filter('acf/pre_load_value', 'wm_fix_repeater_gutenberg', 10, 3);

    Best regards.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.