Support

Account

Home Forums Backend Issues (wp-admin) Pre populate repeater in a flexible content

Solved

Pre populate repeater in a flexible content

  • Hello,

    I’m trying to pre populate a repeater inside a flexible content, using:

    add_filter( 'acf/load_value/key=field_mykey', 'default_fields', 10, 3 );
    add_filter( 'acf/load_value/name=content_name', 'default_fields', 10, 3 );

    I’m able to:
    – populate a repeater outside a flexible content
    – populate a flexible content with a block

    but I’m not able to pre populate a repeater inside a flexible content added dynamically with the button “add block”…

    So what I would like to achieve is:
    – create a new post
    – the flexible content is empty
    – click “add block” and add the pre populated repeater

    is it somehow possible?

    many thanks
    Francesco

  • any suggestion on how to fix this?

  • I haven’t found a solution for this but I found another solution that fit my problem, with this code is possible to pre-populate nested fields with some default value:

    add_filter('acf/load_value/key=field_607879a1215fc',  'acf_load_default', 10, 3);
    function acf_load_default($value, $post_id, $field)
    {
    
      if ($value === false) {
    
        $value = array();
    
        $value[] = array(
          'field_6081eeaf5a418' => 'Example Title One',
        );
        $value[] = array(
          'field_6081eeaf5a418' => 'Example Title Two',
          'field_6081eeb75a419' => array(
            array('field_6081eebf5a41a' => 'Example Title Three'),
            array('field_6081eebf5a41a' => 'Example Title Four')
          )
        );
      }
    
      return $value;
    }
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.