Support

Account

Home Forums Add-ons Repeater Field Repeater field and checkbox Reply To: Repeater field and checkbox

  • Hi @whoaloic

    Hmm… A checkbox field will return an array of the selected values. You could use in_array() function to to determine if a certain value is within the array as shown below:

    if( have_rows('repeater_field_name') ):
    
     
        while ( have_rows('repeater_field_name') ) : the_row();
    
            $value = get_sub_field('checkbox_field_name');
    
            if(in_array('value1', $value)) {
            	// display subfields
            } else if(in_array('value2', $value)) {
            	// display other subfields
            }
    
        endwhile;
    
    else :
    
        // no rows found
    
    endif;

    For more info, check out:http://php.net/manual/en/function.in-array.php