Skip to main content

Introduction

Filament includes several prebuilt actions that simplify common Eloquent operations. These actions come with sensible defaults, automatic authorization, notifications, and full customization options.

Available prebuilt actions

The following actions are available out of the box:
  • CreateAction - Create new records with a form
  • EditAction - Edit existing records
  • ViewAction - View records in read-only mode
  • DeleteAction - Delete records with confirmation
  • ReplicateAction - Duplicate existing records
  • ForceDeleteAction - Permanently delete soft-deleted records
  • RestoreAction - Restore soft-deleted records
  • ImportAction - Import data from files
  • ExportAction - Export data to files

Create action

The create action opens a modal with a form to create new Eloquent records:
1
Basic usage
2
use Filament\Actions\CreateAction;
use Filament\Forms\Components\TextInput;

CreateAction::make()
    ->schema([
        TextInput::make('title')->required(),
        TextInput::make('slug')->required(),
    ])
3
Mutating data before saving
4
Modify form data before it’s saved to the database:
5
CreateAction::make()
    ->mutateDataUsing(function (array $data): array {
        $data['user_id'] = auth()->id();
        $data['created_at'] = now();
        
        return $data;
    })
6
Customizing the creation process
7
Take full control of how records are created:
8
use Illuminate\Database\Eloquent\Model;

CreateAction::make()
    ->using(function (array $data, string $model): Model {
        $record = $model::create($data);
        $record->attachDefaultTags();
        
        return $record;
    })

Creating another record

The create action includes a “Create & create another” button by default:
CreateAction::make()
    ->createAnother(false) // Disable the feature
Preserve form data when creating another record:
CreateAction::make()
    ->preserveFormDataWhenCreatingAnother(['category_id', 'is_published'])

Edit action

The edit action opens a modal with a form pre-filled with the record’s data:
1
Basic usage
2
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;

EditAction::make()
    ->schema([
        TextInput::make('title')->required(),
        TextInput::make('slug')->required(),
    ])
3
Mutating data before filling
4
Modify the record’s data before filling the form:
5
EditAction::make()
    ->mutateRecordDataUsing(function (array $data): array {
        $data['formatted_price'] = number_format($data['price'], 2);
        
        return $data;
    })
6
Mutating data before saving
7
Modify form data before saving:
8
EditAction::make()
    ->mutateDataUsing(function (array $data): array {
        $data['last_edited_by_id'] = auth()->id();
        $data['updated_at'] = now();
        
        return $data;
    })

Delete action

The delete action requires confirmation before deleting records:
use Filament\Actions\DeleteAction;

DeleteAction::make()

Bulk delete action

Allow users to delete multiple records at once:
use Filament\Actions\DeleteBulkAction;
use Filament\Tables\Table;

public function table(Table $table): Table
{
    return $table
        ->bulkActions([
            DeleteBulkAction::make(),
        ]);
}

Optimizing bulk deletes

For large datasets, use chunking to reduce memory usage:
DeleteBulkAction::make()
    ->chunkSelectedRecords(250)
Skip loading records into memory for better performance:
DeleteBulkAction::make()
    ->fetchSelectedRecords(false) // Deletes in a single query
When using fetchSelectedRecords(false), model events and individual record authorization are skipped.

View action

The view action displays record data in read-only form fields:
use Filament\Actions\ViewAction;
use Filament\Forms\Components\TextInput;

ViewAction::make()
    ->schema([
        TextInput::make('title'),
        TextInput::make('slug'),
    ])
All fields are automatically disabled, preventing user edits.

Replicate action

The replicate action duplicates existing records:
1
Basic usage
2
use Filament\Actions\ReplicateAction;

ReplicateAction::make()
3
Excluding attributes
4
Prevent certain columns from being replicated:
5
ReplicateAction::make()
    ->excludeAttributes(['slug', 'created_at', 'updated_at'])
6
Mutating replicated data
7
Modify the data before creating the replica:
8
ReplicateAction::make()
    ->mutateRecordDataUsing(function (array $data): array {
        $data['title'] = $data['title'] . ' (Copy)';
        $data['slug'] = $data['slug'] . '-copy';
        
        return $data;
    })

Lifecycle hooks

Execute code at different points in the replication process:
use Illuminate\Database\Eloquent\Model;

ReplicateAction::make()
    ->beforeReplicaSaved(function (Model $replica): void {
        // Modify the replica before it's saved
        $replica->status = 'draft';
    })
    ->after(function (Model $replica): void {
        // Do something after the replica is saved
        $replica->syncRelationships($this->record);
    })

Soft delete actions

Filament provides specialized actions for Laravel’s soft delete feature:

Force delete action

Permanently delete soft-deleted records:
use Filament\Actions\ForceDeleteAction;

ForceDeleteAction::make()

Restore action

Restore soft-deleted records:
use Filament\Actions\RestoreAction;

RestoreAction::make()

Bulk actions

Both actions have bulk variants:
use Filament\Actions\ForceDeleteBulkAction;
use Filament\Actions\RestoreBulkAction;

ForceDeleteBulkAction::make()
RestoreBulkAction::make()

Customizing notifications

All prebuilt actions dispatch success notifications that you can customize:
CreateAction::make()
    ->successNotificationTitle('Post created successfully')

Redirecting after actions

Customize where users are redirected after an action completes:
CreateAction::make()
    ->successRedirectUrl(route('posts.list'))
Access the created/edited record:
use Illuminate\Database\Eloquent\Model;

CreateAction::make()
    ->successRedirectUrl(fn (Model $record): string => route('posts.show', $record))

Lifecycle hooks

All prebuilt actions support lifecycle hooks for executing code at specific points:
CreateAction::make()
    ->beforeFormFilled(function () {
        // Runs before form fields are populated with defaults
    })
    ->afterFormFilled(function () {
        // Runs after form fields are populated
    })
    ->beforeFormValidated(function () {
        // Runs before validation when submitted
    })
    ->afterFormValidated(function () {
        // Runs after validation passes
    })
    ->before(function () {
        // Runs before saving to database
    })
    ->after(function () {
        // Runs after saving to database
    })

Halting execution

Stop an action from completing using halt() or cancel():
use Filament\Actions\CreateAction;
use Filament\Notifications\Notification;

CreateAction::make()
    ->before(function (CreateAction $action) {
        if (! $this->user->hasCredits()) {
            Notification::make()
                ->warning()
                ->title('Insufficient credits')
                ->body('Purchase more credits to continue.')
                ->send();
            
            $action->halt(); // Stops execution but keeps modal open
        }
    })
Use cancel() to close the modal:
$action->cancel(); // Stops execution and closes modal

Using wizards

Transform create and edit actions into multi-step wizards:
use Filament\Schemas\Components\Wizard\Step;

CreateAction::make()
    ->steps([
        Step::make('Details')
            ->schema([...]),
        Step::make('Content')
            ->schema([...]),
        Step::make('Settings')
            ->schema([...]),
    ])

Build docs developers (and LLMs) love