Skip to content

Instantly share code, notes, and snippets.

@Asharif88
Created January 26, 2026 11:21
Show Gist options
  • Select an option

  • Save Asharif88/9a6b23abf799ac4b5afb056e42f878ca to your computer and use it in GitHub Desktop.

Select an option

Save Asharif88/9a6b23abf799ac4b5afb056e42f878ca to your computer and use it in GitHub Desktop.
Filament actions issue

I'm having issues consistently passing arguments to Actions, I'm not sure if it's me not understanding the documentation or something else. What I'm trying to do is to have an action change a public property on the component by doing something like this:

Action::make('ChartSource_' . $source->id)
                ->icon(Heroicon::Eye)
                ->label($source->name)
                ->button()
                ->arguments(['source' => $source])
                ->action(function (Source $source, $livewire) {
                    // Ideally I want to do this
                    $this->selectedSource = $source;
                    // However this doesn't work, neither does the below
                    $livewire->dispatch('setChartSource', sourceId: $source->id);

                });

However the Closure doesn't seem to run, I have tried this on a custom widget and on Custom pages, both as a schema inside the body and in header actions. I have also tried to pass arguments through the function ->arguments and the closure is not working If I place the method name as a string inside action like this

Action::make('ChartSource_' . $source->id)
                ->icon(Heroicon::Eye)
                ->label($source->name)
                ->button()
                ->arguments(['source' => $source])
                ->action('changeChartSource');

I'm able to call the method but if I include the arguments in the method, for example like this I'm getting an error

public function changeChartSource(array $arguments): void
{
  $this->updateChartData($arguments);
}
Illuminate\Contracts\Container\BindingResolutionException
vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:198
Unable to resolve dependency [Parameter #0 [ <required> array $arguments ]] in class App\Filament\Resources\Assets\Widgets\AssetHealthPieChart

Adding a default value for the array just gives an empty value.

I'm trying to do this without modifying the blade template, but when I look at the html I see that the arguments are included in mountAction like this

wire:click="mountAction('changeChartData', JSON.parse('{\u0022fromHeader\u0022:true}'))"

But the arguments are missing when I'm outputting the action inside the widget body using something like this:

public function setBodyContent(): null|string|Htmlable|View
    {

        $actions = [
            Action::make('changeChartData')
                ->label('Change Data')
                ->button()
                ->icon(Heroicon::ArrowDownCircle)
                ->color('primary')
                ->arguments(['fromHeader' => false])
                ->action('changeChartData'),
        ];

        return Schema::make($this)
            ->components(Flex::make($actions))
            ->alignStart();
    }

Thanks in advance for any insight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment