Update select with live API data

Hi all, I've got a select which has a suffixAction to reload options from an API:
Select::make('project_id')
->label('Project')
->options($this->projects)
->placeholder('Select a project')
->columnSpan(1)
->required()
->default('1207283586562118')
->suffixAction(
Action::make('refreshProjects')
->label('Refresh projects')
->icon('heroicon-o-arrow-path')
->action(function (Select $component) {
$this->updateProjects();
})

),
Select::make('project_id')
->label('Project')
->options($this->projects)
->placeholder('Select a project')
->columnSpan(1)
->required()
->default('1207283586562118')
->suffixAction(
Action::make('refreshProjects')
->label('Refresh projects')
->icon('heroicon-o-arrow-path')
->action(function (Select $component) {
$this->updateProjects();
})

),
But although updateProjects() does get the correct format data from API, I can't get it to re-load the select box from the new data. Any ideas how to do this? I've searched here, but nothing worked.
1 Reply
krekas
krekas7mo ago
try adding live(). And how does that updateProjects() look? The assign part to the projects property
Want results from more Discord servers?
Add your server