Filament modal doesn't work/show
I just updated my app to livewire version 3,
and filament too.
but my doesn't get trigger when clicked.
the request get sent in the browser but it doesn't get rendered.
30 Replies
@Leandro Ferreira please help
As per the post #✅┊rules please do not tag people
As you are using actions please read:
https://filamentphp.com/docs/3.x/actions/modals
Ok noted
So I need something like banAction() not confirmBan()?
Yes. The method name should match the name in Action::make()
So banAction() and make(‘ban’)
Thanks so much, been scratching my head here.
how do i dynamically set the action label
public function banAction(): Action
{
return Action::make('ban')
->requiresConfirmation()
->label(function (array $arguments) {
$doctor = Doctor::find($arguments['doctor']);
return $doctor->isBanned() ? 'Unban Account' : 'Ban Account';
})
->action(function (array $arguments) {
$doctor = Doctor::find($arguments['doctor']);
if ($doctor->isBanned()) {
$doctor->update(['banned_at' => null]);
} else {
$doctor->ban();
}
})
->successNotification(
Notification::make()
->success()
->title('User updated')
->body('The user has been saved successfully.'),
)
->link();
}
You have to pass the arguments in from the blade view.
{{ ($this->banAction)([‘doctor’ => $doctor]) }}
did that already
works without the label but i need a button that says Ban and Unban,
currently only Ban shows.
Give me a few minutes.
ok bro
ah, yea, when you pass the arguments in like this, they are only set when the ->action() is triggered. so you'd need another way to set the label without expecting arguments.
since the label is getting processed before the action is run
in my head though it should still work.
what do you get when you dd($arguments) in the label callback
Also, is the action inside a loop?
yes, it's inside a loop
array:1 [▼ // app/Http/Livewire/Pod/Pages/Doctors/Pages/ListDoctors.php:174
"doctor" => 552797238265907
]
hmm. arguments is working for me in label
just puzzled on why i still get that error
can i use wire:click="{{$this->banAction($doctor)}}"
doesn't work
try this:
i know it's ugly, just trying to figure something out.
could also define ->arguments(['doctor' => null]) on the action to guarantee that it has it in the arguments array.
i'm just not sure why it isn't working for you.
Works like a charm thanks.
this is what i need
testing in one of my components it's working fine
Thanks but 1 more issue.
my notification doesn't show
drop the successNotification() and just call it in your ->action()
ok bro
if it forces the label to change correctly, do you even need a notification?
i need notification because i want the user to know know if an action was successful or not
right, but the label changing is a result of the action, so it is an indicator. 🙂
no worries, though, just a thought.
well, that's not visible cause it's actually in a dropdown
ah, didn't know that. Carry on. lol.
ok bro, thanks