Support

Account

Home Forums Add-ons Repeater Field Minimum Rows 1 empty fields shows as value Reply To: Minimum Rows 1 empty fields shows as value

  • That’s because with 1 row, when you save the post ACF created the row and adds the blank content. So have_rows() is true and it loops through the rows to show them, even though they are blank.

    You’ll need to loop though the fields to see if there’s actually anything in them before showing them

    
    
    if( get_field('product_watt_replacement') ) {
        while ( have_rows('product_watt_replacement') ) : the_row();
             $value = get_sub_field('watt_replacement');
             if ($value) {
        	     $array2[] = get_sub_field('watt_replacement')  .'w'; 
             }
        endwhile;
        if (count($array2[])) {
            $content .=  '<tr><td>' . 'Wattage Replacement</td><td>'; 
        	$watt = implode(', ', $array2);
            $content .=  $watt .'</td></tr>';
        }
    }