Support

Account

Home Forums Backend Issues (wp-admin) Change ACF Select field Dynamically Based on Repeater Field values for every cus

Unread

Change ACF Select field Dynamically Based on Repeater Field values for every cus

  • I have two a repeater field inside a group field and a select field. What I’m trying to do is get strings from repeater field to select field dynamically for every custom post. I tried ACF codex code but when I try to edit these post type’s pages, it returns with 503 service error.

    My functions.php Code

    function select_my_field( $field ) {
    
        global $post;
    
        if( have_rows('dies_and_hand_tools_product', $post->ID) ): while ( have_rows('dies_and_hand_tools_product', $post->ID) ) : the_row(); 
    
            if( have_rows('applicable_products', $post->ID) ): while ( have_rows('applicable_products', $post->ID) ) : the_row(); 
    
                    $choices[get_sub_field('applicable_product_name')] = get_sub_field('applicable_product_name');
    
                endwhile; endif;
        
        endwhile; endif;
        
        $field['choices'] = $choices;            
    
        return $field;
    }
    
    add_filter( 'acf/load_field/key=field_5ffc592f83066', 'select_my_field' );

    what I’am trying to reach

    dies_and_hand_tools_product(Group) -> applicable_products(Repeater) -> applicable_product_name(text)

    What I’am trying to change

    dies_and_hand_tools_product(Group) -> dh_product_table(Group) -> applicable_with(select)(key: field_5ffc592f83066)

    null

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.