F
Filament5mo ago
uendel

I can't change default create action's notification title

I have a simple createAction in a form, and I want to change the notification success title, I'm following the documentation https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create#customizing-the-save-notification, but this is not working on my listUsers class.
<?php

namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;

class ListUsers extends ListRecords
{
protected static string $resource = UserResource::class;

public function getTitle(): string
{
return trans('filament-user::user.resource.title.list');
}

protected function getActions(): array
{
return [
CreateAction::make()
->successNotificationTitle('User Created Successfully!'),
];
}
}
<?php

namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;

class ListUsers extends ListRecords
{
protected static string $resource = UserResource::class;

public function getTitle(): string
{
return trans('filament-user::user.resource.title.list');
}

protected function getActions(): array
{
return [
CreateAction::make()
->successNotificationTitle('User Created Successfully!'),
];
}
}
4 Replies
_andypeacock
_andypeacock5mo ago
Agreed, it's not working for me. Nor does the alternative approach listed:
use Filament\Actions\CreateAction;
use Filament\Notifications\Notification;
use <package>\Resources\ProjectResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListProjects extends ListRecords
{
protected static string $resource = ProjectResource::class;

// protected function getHeaderActions() : array
// {
// return [
// Actions\CreateAction::make(),
// ];
// }

protected function getHeaderActions() : array
{
return [
CreateAction::make()
->successNotification(
Notification::make()
->success()
->title('User registered')
->body('The user has been created successfully.'),
)
];
}
}
use Filament\Actions\CreateAction;
use Filament\Notifications\Notification;
use <package>\Resources\ProjectResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListProjects extends ListRecords
{
protected static string $resource = ProjectResource::class;

// protected function getHeaderActions() : array
// {
// return [
// Actions\CreateAction::make(),
// ];
// }

protected function getHeaderActions() : array
{
return [
CreateAction::make()
->successNotification(
Notification::make()
->success()
->title('User registered')
->body('The user has been created successfully.'),
)
];
}
}
In both cases, I just get a green icon with "Created", that's all.
Dennis Koch
Dennis Koch5mo ago
Do you guys use an Action or have a dedicated CreatePage?
uendel
uendelOP5mo ago
That worked for me! Thank you sir!
Want results from more Discord servers?
Add your server