© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
8 replies
Grégoire

Handling dispatch events with named parameters in Filament Action

Hi 👋

I'm trying to dispatch a Wire Element Pro event to open a slide-over from within a reusable Filament action. While this works seamlessly when the action is defined within a Livewire component, it doesn't seem to work as expected in a Filament action.

Here’s the code that works well in a Livewire component:

public function joinTeamAction()
{
    return Action::make('joinTeam')
        ->action(fn() => $this->dispatch('slide-over.open', component: 'settings.team.switch-team-slide-over'));
}
public function joinTeamAction()
{
    return Action::make('joinTeam')
        ->action(fn() => $this->dispatch('slide-over.open', component: 'settings.team.switch-team-slide-over'));
}

However, when I try to achieve the same in a Filament action extended class, I encounter issues. Specifically, I believe the
dispatch
dispatch
method from the
CanDispatchEvent
CanDispatchEvent
trait differs from Livewire's
HandlesEvent
HandlesEvent
logic, causing the following problems:

class JoinTeamAction extends Action
{
    protected function setUp()
    {
        parent::setUp();

        $this
            ->action(function () {
                // Unknown named parameter $component
                $this->dispatch(
                    'slide-over.open',
                    component: 'settings.team.switch-team-slide-over'
                );

                // The event doesn't trigger the slide-over
                $this->dispatch(
                    'slide-over.open',
                    ['component' => 'settings.team.switch-team-slide-over']
                );
            });
    }
}
class JoinTeamAction extends Action
{
    protected function setUp()
    {
        parent::setUp();

        $this
            ->action(function () {
                // Unknown named parameter $component
                $this->dispatch(
                    'slide-over.open',
                    component: 'settings.team.switch-team-slide-over'
                );

                // The event doesn't trigger the slide-over
                $this->dispatch(
                    'slide-over.open',
                    ['component' => 'settings.team.switch-team-slide-over']
                );
            });
    }
}

- Named Parameters: The first approach using named parameters (
component: 'settings.team.switch-team-slide-over'
component: 'settings.team.switch-team-slide-over'
) results in an "Unknown named parameter $component" error.
- Array Syntax: The 2nd approach using an associative array doesn't throw an error, but it fails to trigger the slide-over event as intended.

I also realise that
$this->js()
$this->js()
is not usable in this context either.

Is there a different method or workaround that would allow me to trigger the slide-over event in this context? 🙏
Solution
Actions aren’t livewire components so ‘$this’ is the action in this context. You can inject $livewire into the action callback and call $livewire->dispatch() etc.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Dispatch open modal with parameters
FilamentFFilament / ❓┊help
14mo ago
Triggering Filament Action with a Livewire.dispatch event
FilamentFFilament / ❓┊help
3y ago
wire:loading Not Triggering During Action Dispatch in Filament
FilamentFFilament / ❓┊help
15mo ago
events in filament
FilamentFFilament / ❓┊help
3y ago