NO BUG: ACF dynamic data not returning selected return format for ACF select field

Bricks Version: 1.6.2
**ACF Pro v. 6.0.7

When using ACF dynamic data with an ACF select field

red : Red
green : Green

Bricks echoes the value despite having the label as return field in ACF.

Can anyone confirm this behaviour please?
Thanks
Max

I can’t confirm this behavior. Works as expected for me.

Thank you for your feedback.

Hey Max,
Thank you very much for your report, but I cannot reproduce it either.

Have you figured out why it’s not working for you?

Best regards,
timmse

Hi @timmse & @aslotta

Well, yes and no!
So I did not to mention that I was trying to translate the ACF select field with Polylang (something like this):

add_filter('acf/load_field/name=colours', function($field) {
		$choices = array(
			'red' => pll__('Red'),
			'green' => pll__('Green')
);
		
		$field['choices'] = $choices;
		return $field;
	});

I did register the strings and translated them
eg: pll_register_string('Red', 'Red', 'colour', false);

In ACF the field is set to return the label.

All works fine, when I create a new post I get the language specific variables in the select field (in the HTML source I see the select element has the correct value and Label.

However, when I output the field with {acf_colour} I get the value back (red) instead of the label (Red).

I tried different ways and no win!
So in the end, I created the ACF group for each language and all works properly.

The purpose was to try to avoid duplicating the ACF groups though, maybe you have an idea?

Thanks
Max
PS I know that Polylang is not officially supported :slight_smile:

It works for me using the following code:

<?php

pll_register_string( 'An Option', 'An Option' );
pll_register_string( 'Another Option', 'Another Option' );

add_filter( 'acf/load_field/name=select_me', function( $field ) {
    if ( ! function_exists( 'pll__' ) ) {
        return $field;
    }
    
    $field['choices'] = array_map( function( $choice ) {
        return pll__( $choice );
    }, $field['choices'] );
    
    return $field;
});

Frontend:

2 Likes

@aslotta

Thank you for your time! I’ll give it a try…

EDIT:

It works, however, if I use an_option : An Option it will still return the value instead of the label.
I can work with this solution but I am curious to see is the value : label approach can work too.

Thanks again!!

I am using exactly this and it works for me (using dashes or hyphens for the option value).

Danke André,

At least now I now it works. There must be something on my side that is creating a bug.
I’m going try again with a clean install and see.
Tschüss Max!

Gerne Max.
Tschüss André! :smile: