Dynamic Data into Form Select Field

DISCLAIMER: I can’t get this to work with bricks default form either. Hoping there might be a workaround with BricksForge

I have created a function in PHP to return an array of items to place into a form dropdown.

    function getRelatedCompanyCrews() {
        $myCrews = [];
        array_push($myCrews, 'Hi1');
        array_push($myCrews, 'Hi2');
        return $myCrews;

Then in a select field, I am calling {echo:getRelatedCompanyCrews}. Unfortunately, the array then gets added to the dropdown as one entry that looks like this “Hi1, Hi2” instead of two entries “Hi1” and “Hi2”.

Here is a FB post in the Bricks Community about the issue as well. Redirecting...

It looks like the issue is that Bricks removed a hook (bricks_options_filter) that we could use to catch the actual dropdown and change the output to separate out the returned array to separate values.

Also is there a way to add a “value” to every entry?

Thanks for any help in advance!

Hi @Alphalytics,

I’ve moved this thread to “Feature Requests”, because I cannot find any bug report here :slight_smile: To build the option fields with the return value of a custom PHP function is currently not possible.

But I leave this request open and see what I can do :slight_smile:

1 Like