Home Forums General Issues Select field not showing values that are present


Select field not showing values that are present

  • Hello,

    I used the below ACF tutorial to dynamically populate select fields from a repeater field in an option page. It works intermittently, but then stops working altogether.

    Here is the code I’m using:

    function acf_color_choices( $field ) {

    // Reset choices
    $field['choices'] = array();

    // Check to see if Repeater has rows of data to loop over
    if( have_rows('global_colors', 'option') ) {

    // Execute repeatedly as long as the below statement is true
    while( have_rows('global_colors', 'option') ) {

    // Return an array with all values after the loop is complete

    // Variables
    $value = get_sub_field('global_color');
    $label = get_sub_field('global_color_name');

    // Append to choices
    $field['choices'][ $value ] = $label;


    // Return the field
    return $field;


    add_filter('acf/load_field/name=primary_color', 'acf_color_choices');
    add_filter('acf/load_field/name=secondary_color', 'acf_color_choices');

    Repeater field name is global_colors
    Subfields are global_color and global_color_name

    Select Field Names to grab the repeater field(s) are:
    primary_color and secondary_color

    In short, the values dynamically pull into select fields within the ACF > Field Groups screen, but they do not show up in the select fields themselves. Here is a video of the issue:

    Thanks for your help in advance.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.