Home › Forums › Add-ons › Repeater Field › Repeater only outputting the last row › Reply To: Repeater only outputting the last row
John, thank you for taking the time to help, it is really appreciated.
I was getting errors with your code, but it prompted me to take another look at something i had been trying using get_field() instead.
This is what i have now, which is working
function acf_load_opposition_player_choices( $field ) {
// reset choices
$field['choices'] = array();
$rows = get_field( 'opposition_squad' );
//echo '<pre>';
//print_r( $rows );
//echo '</pre>';
// if has rows
if ( $rows ) {
$i = 1;
foreach ( $rows as $row ) {
//echo $row['opposition_player'];
$value = $row['opposition_player'];
//echo $value;
if ( $i < 18 ) {
$field['choices'][ $value ] = $value;
}
$i++;
}
}
//echo '<pre>';
//print_r( $field );
//echo '</pre>';
// return the field
return $field;
}
add_filter( 'acf/load_field/name=opposition_team_event', 'acf_load_opposition_player_choices' );
I don’t really understand why this would work over the documented method, but its working 😉
Thanks again
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.