FilamentF
Filament12mo ago
Asmit

Actions on loop on livewire

I tried to send array of actions on livewire page and try to triggered it but it wont work.
My Livewire component method
public function getFooterActions(): array
    {
        return [
            Action::make('save')
                ->label('Save')
                ->color('success')
                ->action(function ($livewire) {
                    $livewire->dispatch('myRefresh');
                    $this->dispatch('closeModal');
                }),
            Action::make('cancel')
                ->label('Cancel')
                ->color('gray')
                ->action(function ($livewire) {
                    $livewire->dispatch('myRefresh');
                    $this->dispatch('closeModal');
                }),
        ];
    }

My blade file
<div>
    <x-filament::section>
        <x-slot name="heading">
            Update
        </x-slot>
        {{ $this->form }}
        @foreach($this->getFooterActions() as $action)
            {{ $action }}
        @endforeach
    </x-filament::section>
    <x-filament-actions::modals />
</div>

It shows the action but doesn't work.
Was this page helpful?