reload a Livewire form component after updating the record
I am attempting to refresh a livewire form component after updating the record associated with the form section. I have a form section with a simple schema that just loads a livewire component.
That livewire component uses a mount method to retrieve the record and passes this to an infolist. This all works great on initial load, but I have a section footer action that updates the record and I want the infolist to refresh after update.
The OverrideRecommendation action has a modal form and then updates the record in the action
ViewApplicationRecommendation uses an infolist and includes a mount method to get the record
In the OverrideRecommendation action I can redirect, which would be fine but it doesn't seem as Livewire assorts redirects to url fragments to position the page to the section.
4 Replies
maybe using LW events?
https://livewire.laravel.com/docs/events#listening-for-events
Laravel
Events | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
It seems as though I need to dispatch an event to my livewire component, and i can find the livewire form component via
where this is the form schema
But once I have the Livewire form component, I can't see how to get to the actual ViewApplicantRecommendation component. I looked at the code for Filament\Forms\Components\Livewire but didn't see anything obvious on how to get an instance of the Livewire component passed in the make() method
shouldn't you inject
$livewire
and use $livewire->dispatch('xxx')
?I will try that
Thank you for your help!
That worked.
In my Livewire component class used in the Livewire::make() call in my form,
dispatching the update updates the record for the infolist and the infolist is rendered with the changes from the modal form on the action.
Thanks again. I spent way too much time on this! I appreciate it very much.