Support

Account

Home Forums ACF PRO Backend Select fields from another custom field

Solved

Backend Select fields from another custom field

  • Let me try to explain what i’m trying to do.

    i have a repeater (more than one actually) that will add “strings”/names.

    on another field (a select) i want that the options would be the loop from the repeater field, but this to be done on the backend.

    I don’t know if there is a simplier way, but what i want is that my client could add “Strings”/names/categories and then in another section, select from those “categories/names” and add other info.

    How can this be done?

  • Yes, you use this https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/ and you get the values from the repeater, for example on an options page.

  • thanks.

    my working code if anyone is interested:

    //check select field from .json
    add_filter('acf/load_field/key=field_5af2cece02f00', function( $field ){
         
        // options of the choices to add to select
        $field['choices'] = array();
         
        // dynamic data we want to populate with
    		$bundles = get_field('gerir_marcas', 'option' );
    		//$portfolio = get_field('item_portfolio','option');
     		//var_dump($bundles);
        foreach( $bundles as $bundle ){
            $field['choices'][$bundle['marca']] = $bundle['marca'];
        }
         
        // All done!
        return $field;
         
    } );
  • Hi @josemoreira !

    I’m really interested in that solution. Could I see the full code?

    Thanks a lot in advance 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.