Support

Account

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