Support

Account

Home Forums ACF PRO acf/load_field/ and repeaters Reply To: acf/load_field/ and repeaters

  • Hi,

    I figured out that this is not possible.

    Repeater
    – Repeater
    – – Text Field
    – Repeater
    – – Select Field Loaded from Text Field Above

    The error was Trying to get property of non-object

    So I rethought the data and realized I dould get rid of one of the parent repeater went with this

    – Repeater
    – – Text Field (result_title)
    – Repeater
    – – Select Field Loaded from Text Field Above (yes_complete_target)

    The code then is

    add_filter('acf/load_field/name=yes_complete_target', 'acf_load_complete_field_choices');
    
    function acf_load_complete_field_choices($field){
    
        global $post;
    
        $post_id = $post->ID;
    
        $field['choices'] = array();
    
        //Get the repeater field values
        $choices = get_field( 'dt_result', $post_id );
    
        $keys = array_keys($choices);
        for($i = 0; $i < count($choices); $i++) {
    
            foreach($choices[$keys[$i]] as $key => $value) {
    
                if($key == 'result_title'){
                    $title = $value;
    
                    //echo $value . "<br>";
                    $field['choices'][$title] = $title;
    
                }
            }
        }
    
        return $field;
    
    }