Support

Account

Home Forums Add-ons Flexible Content Field has_sub_field / get_row_layout don't work anymore

Solving

has_sub_field / get_row_layout don't work anymore

  • I have a ‘flexible content’ field configured but it seems the has_sub_field and get_row_layout aren’t working anymore since last updates.

    I’ve made a get_field( ‘custom_tab_menu’ ) of my field name and this is what is at the DB:

    Array
    (
        [0] => Array
            (
                [acf_fc_layout] => related_specific_content
                [destination] => same
                [content] => 53
            )
    
        [1] => Array
            (
                [acf_fc_layout] => map
                [map_contents] => Array
                    (
                        [0] => hotel
                        [1] => tourism
                        [2] => restaurant
                        [3] => bar
                        [4] => casino
                    )
    
                [map_zoom_level] => 15
                [own_location] => 1
            )
    
    )


    But doing this:

    while( has_sub_field( 'custom_tab_menu' ) ) :				
        switch ( get_row_layout() ) :
            case 'map':
                // do something

    Doesn’t iterate as previous. Am I missing anything?

    I appreciate your help.
    Luis

  • My ACF version is 4.3.1 and Flexible Content version 1.1.0

  • Hi @luistinygod

    Can you please do some debugging in your while loop to see what functions are and are not working. Something like this would be good:

    
    <?php 
    
    if( get_field('custom_tab_menu') )
    {
    	echo '<pre>';
    		print_r( 'value exists' );
    	echo '</pre>';
    	
    	$i = 0;
    	
    	while( has_sub_field( 'custom_tab_menu' ) )
    	{
    		$i++;
    		
    		echo '<pre>';
    			print_r( 'Within loop: ' . $i . ', layout: ' . get_row_layout() );
    		echo '</pre>';
    	}
    }
    
    ?>
    

    let me know what you find

    Thanks
    E

  • I’ve changed a little bit your debug script:

    `if( get_field(‘custom_tab_menu’) )
    {
    error_log(‘value exists: ‘. print_r(get_field(‘custom_tab_menu’),true) );
    $i = 0;
    while( has_sub_field( ‘custom_tab_menu’ ) )
    {
    $i++;
    error_log( print_r( ‘Within loop: ‘ . $i . ‘, layout: ‘ . get_row_layout() , true ) ) ;
    }
    }`

    And following the output: You’ll notice that has_sub_field( ‘custom_tab_menu’ ) never instantiates the first value, in this case [acf_fc_layout] => map…

    [29-Nov-2013 13:43:40] value exists: Array
    (
        [0] => Array
            (
                [acf_fc_layout] => map
                [map_contents] => Array
                    (
                        [0] => hotel
                        [1] => tourism
                        [2] => restaurant
                        [3] => bar
                        [4] => casino
                    )
    
                [map_zoom_level] => 15
                [own_location] => 1
            )
    
        [1] => Array
            (
                [acf_fc_layout] => related_specific_content
                [destination] => same
                [content] => 53
            )
    
    )
    
    [29-Nov-2013 13:43:40] Within loop: 1, layout: related_specific_content
  • Hi @luistinygod

    I just wanted to let you know I have fixed a bug in the has_sub_field / have_rows function from another thread:
    http://support.advancedcustomfields.com/forums/topic/latest-version-critical-endless-loop-crashes-sites/#post-8025

    I’m not sure if it will, but can you please apply this update and reload your issue? Perhaps it will also fix the problem you have.

    if not, I’ll look into it shortly.

    Thanks
    E

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

The topic ‘has_sub_field / get_row_layout don't work anymore’ is closed to new replies.