Why would this be fetching data twice?

I have this code in my form for a select field with an action that fetches data. In the class that's fetching data I have a log statement and it's getting executed twice, whenever I click the action button. Why would that be happening?
return $form->schema([
Select::make('account')->options($this->getData())
->searchable()
->multiple()
->suffixAction(
Action::make('refreshAccounts')
->label('') //prevents unstyled tooltip from showing up with "refreshAccounts" in it.
->icon('heroicon-o-arrow-path')
->tooltip('Get latest from Quickbooks')
->action(function () {
$this->getData(forceRefresh: true);
})
)
])->statePath('data');
return $form->schema([
Select::make('account')->options($this->getData())
->searchable()
->multiple()
->suffixAction(
Action::make('refreshAccounts')
->label('') //prevents unstyled tooltip from showing up with "refreshAccounts" in it.
->icon('heroicon-o-arrow-path')
->tooltip('Get latest from Quickbooks')
->action(function () {
$this->getData(forceRefresh: true);
})
)
])->statePath('data');
It's only getting called once on page load.
1 Reply
Dennis Koch
Dennis Koch13mo ago
You should wrap the code for the options in a closure.
Want results from more Discord servers?
Add your server