Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
400 stars 53 forks source link

Issue with `addSelect` Method Returning Incorrect 'value' for Numeric or Single-Character Choices #184

Closed retoolstack closed 7 months ago

retoolstack commented 7 months ago

Update Solved Please refer to

StoutLogic/acf-builder#83

Summary of the Problem:

The addSelect method in ACF Composer/Builder is exhibiting unexpected behavior when handling choices that are either numeric or consist of a single non-whitespace character. Normally, this method should return an array with distinct 'value' and 'label' keys for each choice. However, when the choice key is a single character or a number, the method incorrectly returns the 'label' text as the 'value', rather than the actual key.

        ->addSelect('select_field', [
            'label' => 'Select Field',
            'choices' => [
                '1' => 'choice1',
                '2' => 'choice2'
            ],
            'return_format' => 'array',
        ])

Observed Behavior:

Expected Behavior:

Workaround Observed:

This issue impacts the functionality of the addSelect method, especially in cases where numeric or single-character keys are essential. I tested ACF plugin directly as well and when using acf (not composer) the fields do not have this issue. indicating that this bug is specific to ACF Composer/Builder

The ticket aims to resolve this inconsistency, ensuring that the method returns correct 'value' and 'label' pairs for all types of keys.

mike-sheppard commented 7 months ago

hey @retoolstack it looks like you might be bumping into this issue: https://github.com/StoutLogic/acf-builder/issues/83 ? If not, it'd probably be worth opening a new issue on https://github.com/StoutLogic/acf-builder/

retoolstack commented 7 months ago

Solved Closing This Ticket

hey @retoolstack it looks like you might be bumping into this issue: StoutLogic/acf-builder#83 ? If not, it'd probably be worth opening a new issue on https://github.com/StoutLogic/acf-builder/

Thanks @mike-sheppard

retoolstack commented 7 months ago

yeah that looks like that will solve it i will test now appreciate it I did search the tickets on composer but didn't think to check builder