How to prevent showing Success notification on the Edit page?

I am using a custom button with a custom action on the Edit page. And when pressed, it shows 2 notifications instead of just 1. The first one is the classic Saved successfullly success message that is part of the save buttons. The second one is the custom message of mine I put on the button. Here is the custom-button's code I am using:
Action::make('pending')
->label('Pending')
->action(function () {
$this->data['status'] = 'pending';
$this->save();

$this->refreshFormData([]);

Notification::make()->title("It's pending!")->success()->send();
}),
Action::make('pending')
->label('Pending')
->action(function () {
$this->data['status'] = 'pending';
$this->save();

$this->refreshFormData([]);

Notification::make()->title("It's pending!")->success()->send();
}),
The problem is that not only the "It's pending" notification is shown, but also the "Saved successfully" notification toast as well. How to disable that saved successfully message and show only the my custom notification message?
Solution:
```php ->action(function () { $this->record->update([ 'status' => 'pending', ]);...
Jump to solution
7 Replies
Wirkhof
WirkhofOP9mo ago
I have tried this:
Action::make('pending')
->label('Pending')
->action(function () {
$this->data['status'] = 'pending';

$this->successNotification(null); // <-- added this

$this->save();

$this->refreshFormData([]);

Notification::make()->title("It's pending!")->success()->send();
}),
Action::make('pending')
->label('Pending')
->action(function () {
$this->data['status'] = 'pending';

$this->successNotification(null); // <-- added this

$this->save();

$this->refreshFormData([]);

Notification::make()->title("It's pending!")->success()->send();
}),
But I am getting an error. Also I have tried this:
Action::make('pending')
->label('Pending')
->action(function () {
$this->data['status'] = 'pending';
$this->save();

$this->refreshFormData([]);

Notification::make()->title("It's pending!")->success()->send();
})
->successNotification(null), // <-- added this
Action::make('pending')
->label('Pending')
->action(function () {
$this->data['status'] = 'pending';
$this->save();

$this->refreshFormData([]);

Notification::make()->title("It's pending!")->success()->send();
})
->successNotification(null), // <-- added this
But it also didn't work. No errors shown, but still two toasts are being shown and not just 1.
Vp
Vp9mo ago
Can you post all your data, where did you register, how did you register etc.. I'll try to reproduce
Wirkhof
WirkhofOP9mo ago
I have found this documentation:
Wirkhof
WirkhofOP9mo ago
But I don't know how to mke it work when I have multiple custom button on the edit page and not onlye the default ones. I guess I need to "remove" somehow the Notification for the save() method - I guess $this->save() is triggering it. Or maybe there is another method than save() for manually saving stuff to the dB? What if I just tried DB::table().... something? But it would be super cool if I could do it using Filament methods and stuff Any idea how to make the default Save-notification not to show up after ->save() ?
Solution
Vp
Vp9mo ago
->action(function () {
$this->record->update([
'status' => 'pending',
]);
}),
->action(function () {
$this->record->update([
'status' => 'pending',
]);
}),
Wirkhof
WirkhofOP9mo ago
Yes, it works! Thanks. Only 1 message, the custom one I want, is showing now.
Want results from more Discord servers?
Add your server