Action refresh Select field value

Hello, I'm building an action and trying to refresh the select field but I cannot make it work, can someone point me out how to do that?
->action(function (array $data, Program $record, Select $component): void {
$statePath = $component->getStatePath();

$data['entity']['type'] = 'organizer';
$entity = Entity::create($data['entity']);

$users = !empty($data['users']) ? $data['users'] : [];
foreach ($users as $user) {
$user = User::create($user);
}

$record->entity()->associate($entity->id);
$record->save();

/** @var LivewireComponent $livewire */
$livewire = $component->getLivewire();
$livewire->dispatch('filament-forms::select.refreshSelectedOptionLabel', livewireId: $livewire->getId(), statePath: $statePath);

})
->action(function (array $data, Program $record, Select $component): void {
$statePath = $component->getStatePath();

$data['entity']['type'] = 'organizer';
$entity = Entity::create($data['entity']);

$users = !empty($data['users']) ? $data['users'] : [];
foreach ($users as $user) {
$user = User::create($user);
}

$record->entity()->associate($entity->id);
$record->save();

/** @var LivewireComponent $livewire */
$livewire = $component->getLivewire();
$livewire->dispatch('filament-forms::select.refreshSelectedOptionLabel', livewireId: $livewire->getId(), statePath: $statePath);

})
Thank you in advance,
1 Reply
pimousse7928
pimousse7928OP15mo ago
Ok fixed it by replacing the livewire part by simply "$component->state($entity->id);"
Want results from more Discord servers?
Add your server