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;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.