Skip to main content

Introduction

Actions are one of Filament’s most powerful features, providing modal-based interactions throughout the framework. Custom actions extend the base Action class and can be used in tables, forms, pages, and infolists.

Understanding the Action base class

All actions extend the Action class at packages/actions/src/Action.php. This base class provides:
  • Modal management
  • Form integration
  • Authorization and visibility
  • Notifications
  • URL redirection
  • Event dispatching
  • Lifecycle hooks
  • Multiple view modes (button, link, icon button, grouped)

Creating a basic custom action

Advanced action configuration

Actions support extensive configuration through the fluent API:

Creating bulk actions

Bulk actions operate on multiple selected records:

Using lifecycle hooks

Actions provide comprehensive lifecycle hooks:

Implementing authorization

Control who can see and use your action:

Working with action data

Actions can access and manipulate data from multiple sources:

Creating action groups

Group related actions together:

Advanced example: Multi-step wizard action

Using database transactions

Ensure data consistency with transactions:

Custom action arguments

Pass custom data to actions:

Stopping action execution

You can halt or cancel action execution:

Best practices

  • Use setUp() for default configuration instead of the constructor
  • Implement getDefaultName() for automatic action naming
  • Use lifecycle hooks for complex workflows
  • Always use database transactions for multi-step operations
  • Provide clear modal headings and descriptions
  • Use authorization methods (visible(), authorize(), disabled())
  • Follow naming conventions: use descriptive names, not abbreviations
  • Use static closures when the closure doesn’t use $this
  • Provide success/failure notifications
  • Deselect records after bulk actions complete
  • Use evaluate() for all properties that support closures

Testing custom actions

Test your actions using Pest or PHPUnit: