Support

Account

Home Forums Add-ons Repeater Field acf/load_value for Repeater inside Flexible Content

Helping

acf/load_value for Repeater inside Flexible Content

  • Hi everyone,

    I am trying to pre-populate a repeater field, that is located inside a flexible content field, and need help with figuring out what I am doing wrong.

    I tried add_filter('acf/load_value/name=competitor_table', 'afc_load_my_repeater_value', 10, 3); and add_filter('acf/load_value/key=field_63995a8ada6b0', 'afc_load_my_repeater_value', 10, 3); but it only loads the values after I save and refresh the page.

    I also tried changing the priority to lower or higher, but still no luck.

    My code example that will not work:

    add_filter('acf/load_value/name=competitor_table',  'afc_load_my_repeater_value', 1, 3);
    function afc_load_my_repeater_value($value, $post_id, $field)
    {
    
      $value  = array();
      $value[] = array(
        'field_63995a8ada6b0' => 'Same day physician access',
        'field_63995accda6b1' => 'yes',
        'field_63995b10da6b3' => 'yes',
        'field_63995b17da6b4' => 'no'
      );
      $value[] = array(
        'field_63995a8ada6b0' => 'Physical card copy',
        'field_63995accda6b1' => 'yes',
        'field_63995b10da6b3' => 'yes',
        'field_63995b17da6b4' => 'yes'
      );
      return $value;
    }
  • Is the filter actually being called when creating a new post?

    Add to the top of the function and see if you get output from it

    
    echo '<pre>'; var_dump($value); echo '</pre>';
    

    You should use the field key variant.

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

You must be logged in to reply to this topic.