Listening for events

Hi there, I was wondering where I'm making a mistake? I have a Form Component Select
Forms\Components\Select::make('projectstatus_id')
->relationship('status', 'naam')
->reactive()
->registerListeners([
'updateOptions' => [
function (Forms\Components\Component $component): void {
ray($component);
},
],
])
->label('Current status'),

Forms\Components\Select::make('projectstatus_id')
->relationship('status', 'naam')
->reactive()
->registerListeners([
'updateOptions' => [
function (Forms\Components\Component $component): void {
ray($component);
},
],
])
->label('Current status'),

From withing my custom Livewire component I'm emitting an event
$this->emit('updateOptions');
$this->emit('updateOptions');
This works if I check the events tab of the LiveWire devtools. So how to receive the event from the LiveWire component. The goal is to update the status field with the current status which is changed from within the LiveWire component.
2 Replies
Dan Harrin
Dan Harrin2y ago
yeah events arent the same thing you should register the listener on the livewire component, not the field and then set $this->data['projectstatus_id'] or wherever the status is stored
Tally
TallyOP2y ago
super... will try 😉 thanks for the tip YES... I'm receiving the event! Thanks @Dan Harrin

Did you find this page helpful?