Created
January 26, 2026 11:21
-
-
Save Asharif88/9a6b23abf799ac4b5afb056e42f878ca to your computer and use it in GitHub Desktop.
Revisions
-
Asharif88 created this gist
Jan 26, 2026 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ 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: ```php 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 ```php 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 ```php 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 ```html 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: ```php 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