notification inside action not showing
i have code action like this but when it create, the success notification not fired
how to tackle this?
thank you!
how to tackle this?
thank you!
->suffixAction(
Forms\Components\Actions\Action::make('newCategoryForAsset')
->icon('heroicon-m-squares-plus')
->form([
Forms\Components\TextInput::make('name')
->maxLength(255)
->required(),
Forms\Components\TextArea::make('note')
])
->mutateFormDataUsing(function (array $data): array {
$data['type'] = 'Asset';
$data['user_id'] = auth()->id();
return $data;
})
->successNotification(function (array $data){
Notification::make()
->title('Category registered')
->body('Saved new '.$data['type'].' category named '.$data['name'].'.')
->success();
})
->action(function (array $data): void {
Category::create($data);
})
),->suffixAction(
Forms\Components\Actions\Action::make('newCategoryForAsset')
->icon('heroicon-m-squares-plus')
->form([
Forms\Components\TextInput::make('name')
->maxLength(255)
->required(),
Forms\Components\TextArea::make('note')
])
->mutateFormDataUsing(function (array $data): array {
$data['type'] = 'Asset';
$data['user_id'] = auth()->id();
return $data;
})
->successNotification(function (array $data){
Notification::make()
->title('Category registered')
->body('Saved new '.$data['type'].' category named '.$data['name'].'.')
->success();
})
->action(function (array $data): void {
Category::create($data);
})
),Solution
I think
successNotificationsuccessNotification will be used to override the default filament actions, so you dont need it hereForms\Components\Actions\Action::make('newCategoryForAsset')
->action(function (array $data): void {
Category::create($data);
Notification::make()
->title('Category registered')
->body('Saved new '.$data['type'].' category named '.$data['name'].'.')
->send()
->success();
})Forms\Components\Actions\Action::make('newCategoryForAsset')
->action(function (array $data): void {
Category::create($data);
Notification::make()
->title('Category registered')
->body('Saved new '.$data['type'].' category named '.$data['name'].'.')
->send()
->success();
})