Receive parameters from programmatic action
I call an action from a livewire component, like this:
<div wire:click="mountAction('addData', { id: {{$event['id']}} })"
And this is the method that is called:
public function addDataAction(array $options = []): Action
{
ray($options);
return Action::make('New data')->slideOver()
->form(
CustomForm::getForm([
'type' => 'activity',
]),
)
->action(function (array $arguments) {
dd('Test action called', $arguments);
});
}
I was hoping that I could receive the id as a parameter inside my addDataAction, so that I can change the form and title depending on the input. How can i receive the parameters in the method?
3 Replies
Okay I found this (mountedActionsArguments):
public function addAppointmentAction(array $arguments = []): Action
{
ray($this->mountedActionsArguments);
}
Is that the way?I think so
$arguments
will be available in the action according to the docs
https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#programmatically-triggering-actionsYeah but that is a layer deeper, in the action itself:
->action(function (array $arguments) {
I need it in the function addAppointmentAction, so i can change the title and fields of my form. I think that $this->mountedActionsArguments will work for now.