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

    • manidar

    • January 14, 2021 at 1:20 am

    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.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.