Support

Account

Home Forums Add-ons Repeater Field If repeater subfield has this value in any row : do something Reply To: If repeater subfield has this value in any row : do something

  • The only way that you can find if any row has the true false field set to true is to loop over the entire repeater and test every rows. When you use

    
    $rows = get_field('repeater');
    

    the format of $rows will be something like

    
    $rows = array(
      // each row is a nested array
      array(
        // each subfield is a key => value pair
        'sub_field' => 'value'
      )
    )
    
    
    $has_true = false;
    foreach ($rows as $row) {
      if ($row['sub_field'])) {
        $has_true = true;
        break;
      }
    }
    
    if ($has_true) {
      // do something
    }