FilamentF
Filament2y ago
Ron

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.

 Section::make('Applicant Recommendation)
            ->schema([
                Livewire::make(ViewApplicantRecommendation::class)
             ->key('view-applicant-recommendation'),
            ])
            ->footerActions([
                OverrideRecommendation::action(),
            ])->footerActionsAlignment(Alignment::End);

The OverrideRecommendation action has a modal form and then updates the record in the action
 ->action(function (array $data, Order $record, Component $livewire) {
                $record->recommendation->update([
                    'recommendation' => $data['override_recommendation'],
                ]);

ViewApplicationRecommendation uses an infolist and includes a mount method to get the record
  public ?Order $record = null;
  public function mount(?Order $record = null): void
    {
        $this->record = $record;
    }
     public function recommendationInfolist(Infolist $infolist): Infolist
    {

        return $infolist
            ->record($this->record)
            ->schema([
                $this->getReasonsRepeatableEntry(),
            ]);
    }

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.
Was this page helpful?