Skip to content

Instantly share code, notes, and snippets.

@leek
Created November 3, 2025 13:36
Show Gist options
  • Select an option

  • Save leek/be1576dd6db48b6870a0ec3ca679310d to your computer and use it in GitHub Desktop.

Select an option

Save leek/be1576dd6db48b6870a0ec3ca679310d to your computer and use it in GitHub Desktop.
Show "{Model} created" + "Go to record" button after CreateAction in Filament PHP.
<?php
use Filament\Actions;
use Filament\Notifications\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Facades\Filament;
public function boot(): void
{
Actions\CreateAction::configureUsing(function (Actions\CreateAction $action): void {
$action
->successNotification(
Notification::make()
->success()
->persistent() // Optional: Keeps it open until dismissed
->title(function () use ($action) {
$record = $action->getRecord();
$resource = $action->getLivewire()?->getResource();
if (! $record || ! $resource) {
return 'Record created';
}
return sprintf('%s created', $resource::getModelLabel());
})
->body('The record has been created successfully.')
->actions([
Actions\Action::make('go-to-record')
->label('Go to record')
->icon('heroicon-o-arrow-right')
->button() // Or ->link() for text style
->color('primary')
->url(function () use ($action) {
$record = $action->getRecord();
$resource = $action->getLivewire()?->getResource();
if (! $record || ! $resource) {
return null;
}
$page = 'edit';
if (! $resource::hasPage('edit')) {
$page = 'view';
}
return $resource::getUrl($page, [
'tenant' => Filament::getTenant(),
'record' => $record,
], shouldGuessMissingParameters: true);
})
])
)
;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment