Support

Account

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

Helping

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.

  • Has there been any progress on this? I have a repeater field with a minimum of 2 items and in the repeater a WYSIWYG block, which have default (some Lorem ipsum text) and when I add a block to the Gutenberg editor a completely empty block is shown. If I click the editor and edit the content the preview becomes visible.

    The code above does nothing for me (or do I need to change some values to my field names?)

    I made a screencast to better illustrate the issue. As you can se when you edit the block it becomes visible

    https://www.youtube.com/watch?v=IzM-OMoHbWQ

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘ACF Blocks with a repeater field empty in Admin’ is closed to new replies.