Support

Account

Home Forums Gutenberg InnerBlocks Template Pre-populate ACF Repeater

Solved

InnerBlocks Template Pre-populate ACF Repeater

  • Hello,

    Can anyone help me with pre-populated ACF repeater in innerblock template?

    
    $template = array(
        array('core/heading', array(
            'level' => 2,
            'placeholder' => 'Schrijf de titel',
        )),
        array('core/paragraph', array(
            'placeholder' => 'Schrijf tekst',
        )),
    
        This is a repeater field with 3 sub_fields -  Link  -  Color  -  Icon
        array('acf/tf-buttons', array(
        )),
    
        Something like this?
        array('acf/tf-buttons', array('data' => array('text_field'=> 'Test!'))),
    );
    
    global $allowed_jsx_blocks;
    echo '<InnerBlocks template="' . esc_attr( wp_json_encode( $template ) ) . '" allowedBlocks="' . esc_attr( wp_json_encode( $allowed_jsx_blocks ) ) . '" />';
    

    I have this problem often and never found a solution to Pre Populate acf repeater fields

    I tried this, but doesn’t fill the repeater field:

    
    This is a simpel repeater field with one text field
    
    array('acf/tf-buttons',
        array('data' =>
            array('test_rep'=>
                array('data' =>
                    array('test_rep_text'=> 'test')
                )
            )
        )
    ),
    
  • If you’re looking for assistance with a pre-populated Advanced Custom Fields (ACF) repeater in an inner block template, consider contacting skilled developers or seeking online tutorials offering step-by-step guidance. Trolling forums or communities dedicated to WordPress products could also provide valuable insights. Remember, industry and thorough research often produce fruitful results. For additional help with your specific ACF needs, technical platforms offering technical support might be helpful. Lastly, if you require assistance with academic tasks, consider seeking the Best Assignment Writing Help UK to ensure top-notch quality and timely submissions.

  • I am a skilled developer.. There is no information online that explains how to pre-populate repeater fields in a Innerblock template.

    There are some tutorials/information about pre-population fields in a Innerblock template but nothing about repeater fields.

    So thanks for your offer but I’m searching for a simple push in the right direction. And i’m pretty close with the array stacking in my last code snippet.

  • Got the solution 🙂
    If you want to repeat an other button change 0 to 1

    
    array('tatof/button', array(
        'data' => [
            'template_buttons_0_tb_button' => [
                'title' => 'Button title',
                'url' => '#',
                'target' => ''
            ],
            '_template_buttons_0_tb_button' => 'field_637e1739ba382',
    
            'template_buttons_0_tb_color' => 'primary',
            '_template_buttons_0_tb_color' => 'field_637e1750ba383',
    
            'template_buttons_0_tb_icon' => '',
            '_template_buttons_0_tb_icon' => 'field_637e18cfba384',
    
            'template_buttons' => 1,
            '_template_buttons' => 'field_637e171dba381',
        ]
    )),
    
  • Repeater:

    
    'template' => array(
        array('core/columns', array(), array(
            array('core/column', array(), array(
    
                array('core/paragraph', array(
                    'placeholder' => 'Intro tekst hier'
                )),
                array('tatof/button', array(
                    'data' => [
    
                        // Button one
                        'template_buttons_0_tb_button' => [
                            'title' => 'Voorbeeld knop',
                            'url' => '#',
                            'target' => ''
                        ],
                        '_template_buttons_0_tb_button' => 'field_637e1739ba382',
                        'template_buttons_0_tb_color' => 'secondary',
                        '_template_buttons_0_tb_color' => 'field_637e1750ba383',
                        'template_buttons_0_tb_icon' => '',
                        '_template_buttons_0_tb_icon' => 'field_637e18cfba384',
    
                        // Button two
                        'template_buttons_1_tb_button' => [
                            'title' => 'Voorbeeld twee',
                            'url' => '#',
                            'target' => ''
                        ],
                        '_template_buttons_1_tb_button' => 'field_637e1739ba382',
                        'template_buttons_1_tb_color' => 'primary',
                        '_template_buttons_1_tb_color' => 'field_637e1750ba383',
                        'template_buttons_1_tb_icon' => '',
                        '_template_buttons_1_tb_icon' => 'field_637e18cfba384',
                        'template_buttons' => 2,
                        '_template_buttons' => 'field_637e171dba381',
                    ]
                )),
            )),
            array('core/column', array(), array(
    
                array('acf/tf-image', array()),
    
            )),
        )),
    ),
    
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.