How can I dynamically update my Select options based on an API

I've got a textInput where a user can enter their zipcode/postcode and a button that does a lookup via an API.

I'd like to find a way to make the options in the Select update. Is it possible?

private $addresses;
...

TextInput::make('addressLookupText')
                ->label('Address Lookup'),
            Actions::make([
                Action::make('Address Lookup Button')
                    ->label('Find Address')
                    ->action(function (Get $get) {
                        $this->addresses = $this->findAddresses($get('addressLookupText'));
                    }),
            ]),
            Select::make('addresses')
                ->options($this->addresses)
                ->label('Select an address'),
Solution
Why two separate fields? I’m doing something similar but with just one select (using the getSearchResultsUsing method on the select). Works great. When a result is selected I also set some other fields.
Was this page helpful?