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
code eater
code eater12mo ago
code eater
code eater12mo ago
@Leandro Ferreira please help
toeknee
toeknee12mo ago
As per the post #✅┊rules please do not tag people
code eater
code eater12mo ago
Ok noted So I need something like banAction() not confirmBan()?
awcodes
awcodes12mo ago
Yes. The method name should match the name in Action::make() So banAction() and make(‘ban’)
code eater
code eater12mo ago
Thanks so much, been scratching my head here.
code eater
code eater12mo ago
code eater
code eater12mo ago
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(); }
awcodes
awcodes12mo ago
You have to pass the arguments in from the blade view. {{ ($this->banAction)([‘doctor’ => $doctor]) }}
code eater
code eater12mo ago
did that already
code eater
code eater12mo ago
works without the label but i need a button that says Ban and Unban, currently only Ban shows.
awcodes
awcodes12mo ago
Give me a few minutes.
code eater
code eater12mo ago
ok bro
awcodes
awcodes12mo ago
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?
code eater
code eater12mo ago
yes, it's inside a loop array:1 [▼ // app/Http/Livewire/Pod/Pages/Doctors/Pages/ListDoctors.php:174 "doctor" => 552797238265907 ]
awcodes
awcodes12mo ago
hmm. arguments is working for me in label
code eater
code eater12mo ago
just puzzled on why i still get that error can i use wire:click="{{$this->banAction($doctor)}}" doesn't work
awcodes
awcodes12mo ago
try this:
->label(function (array $arguments) {
$doctor = Doctor::find($arguments['doctor'] ?? null);

if ($doctor) {
return $doctor->isBanned() ? 'Unban Account' : 'Ban Account';
}

return 'Ban Account';
})
->label(function (array $arguments) {
$doctor = Doctor::find($arguments['doctor'] ?? null);

if ($doctor) {
return $doctor->isBanned() ? 'Unban Account' : 'Ban Account';
}

return 'Ban Account';
})
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.
code eater
code eater12mo ago
Works like a charm thanks. this is what i need
awcodes
awcodes12mo ago
testing in one of my components it's working fine
code eater
code eater12mo ago
Thanks but 1 more issue. my notification doesn't show
awcodes
awcodes12mo ago
drop the successNotification() and just call it in your ->action()
->action(function() {
...do stuff
Notification::make()
->success()
->title('User updated')
->body('The user has been saved successfully.')
->send();
})
->action(function() {
...do stuff
Notification::make()
->success()
->title('User updated')
->body('The user has been saved successfully.')
->send();
})
code eater
code eater12mo ago
ok bro
awcodes
awcodes12mo ago
if it forces the label to change correctly, do you even need a notification?
code eater
code eater12mo ago
i need notification because i want the user to know know if an action was successful or not
awcodes
awcodes12mo ago
right, but the label changing is a result of the action, so it is an indicator. 🙂 no worries, though, just a thought.
code eater
code eater12mo ago
well, that's not visible cause it's actually in a dropdown
awcodes
awcodes12mo ago
ah, didn't know that. Carry on. lol.
code eater
code eater12mo ago
ok bro, thanks