Support

Account

Home Forums ACF PRO Different Default Value For Repeater Field Rows Reply To: Different Default Value For Repeater Field Rows

  • You could try using acf/prepare_field https://www.advancedcustomfields.com/resources/acfprepare_field/

    This example is using a text field, not a select field, just to give you some idea of what you could do.

    
    add_filter('acf/prepare_field/key=field_576ac7aa4eea4', 'preparefield');
    function preparefield($field) {
      // see all the field settings before changing
      echo '<pre>'; print_r($field); echo '</pre>';
      
      // get the current row
      if (preg_match('/([0-9]+)\]$/', $field['prefix'], $matches)) {
        $row = intval($matches[1]);
        // set default value based on row
        $field['default_value'] = $row;
      }
      return $field;
    }