Support

Account

Home Forums Add-ons Flexible Content Field Repeating the same element will preserve the previous value

Helping

Repeating the same element will preserve the previous value

  • Sorry, I am not good at English.

    I am using the PRO version.
    A problem occurred using Flexible content Field.
    Repeating the same element will preserve the previous value.

    ex)
    First input
    textarea ‘This is text’
    image none

    Second input
    textarea none
    image picture set

    result
    First display
    ‘This is text’ only

    Second display
    ‘This is text’ and picture

    The code

    
    if( have_rows('bodyset') ):
    while ( have_rows('bodyset') ) : the_row();
    	if( have_rows('section') ):
    	while ( have_rows('section') ) : the_row();
        		if( get_row_layout() == 'text_pic' ):
        		$text_pic_text_text=get_sub_field('text_pic_text_text');
        		$text_pic_pic_pic=get_sub_field('text_pic_pic_pic');
        		if($text_pic_text_text){echo $text_pic_text_text;}
        		if($text_pic_pic_pic){echo '<img src="'.$text_pic_pic_pic["url"].'">';}
    	endwhile;
    	endif;
    endwhile;
    endif;
    

    I initialized $text_pic_text_text and $text_pic_pic_pic but it was useless.
    $text_pic_text_text=”;
    $text_pic_pic_pic=”;

    $text_pic_text_text=array();
    $text_pic_text_pic=array();
    $text_pic_text_text=”;
    $text_pic_pic_pic=”;

    unset($text_pic_text_text);
    unset($text_pic_pic_pic);

    Please show the way to solve it.
    (I am not good at English, so please write with code or easy words.)

  • It solved it.
    I forgot to initialize.

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

The topic ‘Repeating the same element will preserve the previous value’ is closed to new replies.