Fix imports

This commit is contained in:
Dan Harrin
2024-06-24 18:38:01 +01:00
parent f505913d9d
commit 5fad9fc09f
57 changed files with 437 additions and 162 deletions
+7 -2
View File
@@ -54,7 +54,9 @@ Action::make('updateAuthor')
You may fill the form with existing data, using the `fillForm()` method:
```php
use App\Models\Post;use App\Models\User;use Filament\Forms\Components\Select;
use App\Models\Post;
use App\Models\User;
use Filament\Forms\Components\Select;
Action::make('updateAuthor')
->fillForm(fn (Post $record): array => [
@@ -77,7 +79,10 @@ Action::make('updateAuthor')
You may create a [multistep form wizard](../forms/layout/wizard) inside a modal. Instead of using a `form()`, define a `steps()` array and pass your `Step` objects:
```php
use Filament\Forms\Components\MarkdownEditor;use Filament\Forms\Components\TextInput;use Filament\Forms\Components\Toggle;use Filament\Schema\Components\Wizard\Step;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schema\Components\Wizard\Step;
Action::make('create')
->steps([
@@ -23,7 +23,9 @@ CreateAction::make()
If you want to add this action to the header of a table instead, you can use `Filament\Tables\Actions\CreateAction`:
```php
use Filament\Actions\CreateAction;use Filament\Forms\Components\TextInput;use Filament\Tables\Table;
use Filament\Actions\CreateAction;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -153,7 +155,9 @@ CreateAction::make()
At any time, you may call `$action->halt()` from inside a lifecycle hook or mutation method, which will halt the entire creation process:
```php
use App\Models\Post;use Filament\Actions\Action;use Filament\Notifications\Notification;
use App\Models\Post;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
CreateAction::make()
->before(function (CreateAction $action, Post $record) {
@@ -186,7 +190,10 @@ $action->cancel();
You may easily transform the creation process into a multistep wizard. Instead of using a `form()`, define a `steps()` array and pass your `Step` objects:
```php
use Filament\Forms\Components\MarkdownEditor;use Filament\Forms\Components\TextInput;use Filament\Forms\Components\Toggle;use Filament\Schema\Components\Wizard\Step;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schema\Components\Wizard\Step;
CreateAction::make()
->steps([
@@ -23,7 +23,9 @@ EditAction::make()
If you want to edit table rows, you can use the `Filament\Tables\Actions\EditAction` instead:
```php
use Filament\Actions\EditAction;use Filament\Forms\Components\TextInput;use Filament\Tables\Table;
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -166,7 +168,10 @@ EditAction::make()
At any time, you may call `$action->halt()` from inside a lifecycle hook or mutation method, which will halt the entire saving process:
```php
use App\Models\Post;use Filament\Actions\Action;use Filament\Actions\EditAction;use Filament\Notifications\Notification;
use App\Models\Post;
use Filament\Actions\Action;
use Filament\Actions\EditAction;
use Filament\Notifications\Notification;
EditAction::make()
->before(function (EditAction $action, Post $record) {
@@ -23,7 +23,9 @@ ViewAction::make()
If you want to view table rows, you can use the `Filament\Tables\Actions\ViewAction` instead:
```php
use Filament\Actions\ViewAction;use Filament\Forms\Components\TextInput;use Filament\Tables\Table;
use Filament\Actions\ViewAction;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -16,7 +16,10 @@ DeleteAction::make()
If you want to delete table rows, you can use the `Filament\Tables\Actions\DeleteAction` instead, or `Filament\Tables\Actions\DeleteBulkAction` to delete multiple at once:
```php
use Filament\Actions\BulkActionGroup;use Filament\Actions\DeleteAction;use Filament\Actions\DeleteBulkAction;use Filament\Tables\Table;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -16,7 +16,8 @@ ReplicateAction::make()
If you want to replicate table rows, you can use the `Filament\Tables\Actions\ReplicateAction` instead:
```php
use Filament\Actions\ReplicateAction;use Filament\Tables\Table;
use Filament\Actions\ReplicateAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -119,7 +120,9 @@ ReplicateAction::make()
At any time, you may call `$action->halt()` from inside a lifecycle hook, which will halt the entire replication process:
```php
use App\Models\Post;use Filament\Actions\Action;use Filament\Notifications\Notification;
use App\Models\Post;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
ReplicateAction::make()
->before(function (ReplicateAction $action, Post $record) {
@@ -16,7 +16,10 @@ ForceDeleteAction::make()
If you want to force-delete table rows, you can use the `Filament\Tables\Actions\ForceDeleteAction` instead, or `Filament\Tables\Actions\ForceDeleteBulkAction` to force-delete multiple at once:
```php
use Filament\Actions\BulkActionGroup;use Filament\Actions\ForceDeleteAction;use Filament\Actions\ForceDeleteBulkAction;use Filament\Tables\Table;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\ForceDeleteAction;
use Filament\Actions\ForceDeleteBulkAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -16,7 +16,10 @@ RestoreAction::make()
If you want to restore table rows, you can use the `Filament\Tables\Actions\RestoreAction` instead, or `Filament\Tables\Actions\RestoreBulkAction` to restore multiple at once:
```php
use Filament\Actions\BulkActionGroup;use Filament\Actions\RestoreAction;use Filament\Actions\RestoreBulkAction;use Filament\Tables\Table;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\RestoreAction;
use Filament\Actions\RestoreBulkAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -39,7 +39,9 @@ ImportAction::make()
If you want to add this action to the header of a table instead, you can use `Filament\Tables\Actions\ImportAction`:
```php
use App\Filament\Imports\ProductImporter;use Filament\Actions\ImportAction;use Filament\Tables\Table;
use App\Filament\Imports\ProductImporter;
use Filament\Actions\ImportAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -37,7 +37,9 @@ ExportAction::make()
If you want to add this action to the header of a table instead, you can use `Filament\Tables\Actions\ExportAction`:
```php
use App\Filament\Exports\ProductExporter;use Filament\Actions\ExportAction;use Filament\Tables\Table;
use App\Filament\Exports\ProductExporter;
use Filament\Actions\ExportAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -52,7 +54,9 @@ public function table(Table $table): Table
Or if you want to add it as a table bulk action, so that the user can choose which rows to export, they can use `Filament\Tables\Actions\ExportBulkAction`:
```php
use App\Filament\Exports\ProductExporter;use Filament\Actions\ExportBulkAction;use Filament\Tables\Table;
use App\Filament\Exports\ProductExporter;
use Filament\Actions\ExportBulkAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
+20 -6
View File
@@ -22,7 +22,9 @@ Layout components are used to group fields together, and to control how they are
Initialise a field or layout component with the `make()` method, and build a schema array with multiple fields:
```php
use Filament\Forms\Components\RichEditor;use Filament\Forms\Components\TextInput;use Filament\Schema\Schema;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Schema;
public function form(Schema $form): Schema
{
@@ -72,7 +74,9 @@ You can learn more about columns and spans in the [layout documentation](layout/
Let's add a new [`Section`](layout/section) to our form. `Section` is a layout component, and it allows you to add a heading and description to a set of fields. It can also allow fields inside it to collapse, which saves space in long forms.
```php
use Filament\Forms\Components\RichEditor;use Filament\Forms\Components\TextInput;use Filament\Schema\Components\Section;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Section;
[
TextInput::make('title'),
@@ -90,7 +94,9 @@ use Filament\Forms\Components\RichEditor;use Filament\Forms\Components\TextInput
In this example, you can see how the `Section` component has its own `schema()` method. You can use this to nest other fields and layout components inside:
```php
use Filament\Forms\Components\DateTimePicker;use Filament\Forms\Components\Select;use Filament\Schema\Components\Section;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Schema\Components\Section;
Section::make('Publishing')
->description('Settings for publishing this post.')
@@ -116,7 +122,11 @@ In Laravel, validation rules are usually defined in arrays like `['required', 'm
In Filament, you can add validation rules to your fields by using methods like `required()` and `maxLength()`. This is also advantageous over Laravel's validation syntax, since your IDE can autocomplete these methods:
```php
use Filament\Forms\Components\DateTimePicker;use Filament\Forms\Components\RichEditor;use Filament\Forms\Components\Select;use Filament\Forms\Components\TextInput;use Filament\Schema\Components\Section;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Section;
[
TextInput::make('title')
@@ -152,7 +162,9 @@ Since all Filament forms are built on top of Livewire, form schemas are complete
Fields can hide or show based on another field's values. In our form, we can hide the `published_at` timestamp field until the `status` field is set to `published`. This is done by passing a closure to the `hidden()` method, which allows you to dynamically hide or show a field while the form is being used. Closures have access to many useful arguments like `$get`, and you can find a [full list here](advanced#form-component-utility-injection). The field that you depend on (the `status` in this case) needs to be set to `live()`, which tells the form to reload the schema each time it gets changed.
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Forms\Components\DateTimePicker;use Filament\Forms\Components\Select;
use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
[
Select::make('status')
@@ -173,7 +185,9 @@ It's not just `hidden()` - all Filament form methods support closures like this.
Fields can also write data to other fields. For example, we can set the title to automatically generate a slug when the title is changed. This is done by passing a closure to the `afterStateUpdated()` method, which gets run each time the title is changed. This closure has access to the title (`$state`) and a function (`$set`) to set the slug field's state. You can find a [full list of closure arguments here](advanced#form-component-utility-injection). The field that you depend on (the `title` in this case) needs to be set to `live()`, which tells the form to reload and set the slug each time it gets changed.
```php
use Filament\Schema\Components\Utilities\Set;use Filament\Forms\Components\TextInput;use Illuminate\Support\Str;
use Filament\Schema\Components\Utilities\Set;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Str;
[
TextInput::make('title')
+2 -1
View File
@@ -626,7 +626,8 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Actions\Action;use Filament\Forms\Components\Select;
use Filament\Actions\Action;
use Filament\Forms\Components\Select;
Select::make('author_id')
->relationship(name: 'author', titleAttribute: 'name')
@@ -309,7 +309,8 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Actions\Action;use Filament\Forms\Components\CheckboxList;
use Filament\Actions\Action;
use Filament\Forms\Components\CheckboxList;
CheckboxList::make('technologies')
->options([
+8 -3
View File
@@ -581,7 +581,8 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Actions\Action;use Filament\Forms\Components\Repeater;
use Filament\Actions\Action;
use Filament\Forms\Components\Repeater;
Repeater::make('members')
->schema([
@@ -597,7 +598,8 @@ Repeater::make('members')
You can confirm actions with a modal by using the `requiresConfirmation()` method on the action object. You may use any [modal customization method](../../actions/modals) to change its content and behavior:
```php
use Filament\Actions\Action;use Filament\Forms\Components\Repeater;
use Filament\Actions\Action;
use Filament\Forms\Components\Repeater;
Repeater::make('members')
->schema([
@@ -615,7 +617,10 @@ Repeater::make('members')
You may add new [action buttons](../actions) to the header of each repeater item by passing `Action` objects into `extraItemActions()`:
```php
use Filament\Actions\Action;use Filament\Forms\Components\Repeater;use Filament\Forms\Components\TextInput;use Illuminate\Support\Facades\Mail;
use Filament\Actions\Action;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Facades\Mail;
Repeater::make('members')
->schema([
+8 -3
View File
@@ -387,7 +387,8 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Actions\Action;use Filament\Forms\Components\Builder;
use Filament\Actions\Action;
use Filament\Forms\Components\Builder;
Builder::make('content')
->blocks([
@@ -403,7 +404,8 @@ Builder::make('content')
You can confirm actions with a modal by using the `requiresConfirmation()` method on the action object. You may use any [modal customization method](../../actions/modals) to change its content and behavior:
```php
use Filament\Actions\Action;use Filament\Forms\Components\Builder;
use Filament\Actions\Action;
use Filament\Forms\Components\Builder;
Builder::make('content')
->blocks([
@@ -421,7 +423,10 @@ Builder::make('content')
You may add new [action buttons](../actions) to the header of each builder item by passing `Action` objects into `extraItemActions()`:
```php
use Filament\Actions\Action;use Filament\Forms\Components\Builder;use Filament\Forms\Components\TextInput;use Illuminate\Support\Facades\Mail;
use Filament\Actions\Action;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Facades\Mail;
Builder::make('content')
->blocks([
@@ -165,7 +165,8 @@ This field uses action objects for easy customization of buttons within it. You
Here is an example of how you might customize an action:
```php
use Filament\Actions\Action;use Filament\Forms\Components\KeyValue;
use Filament\Actions\Action;
use Filament\Forms\Components\KeyValue;
KeyValue::make('meta')
->deleteAction(
+2 -1
View File
@@ -32,7 +32,8 @@ We pass an array to `columns()` as we want to specify different numbers of colum
Inside the section, we have a [text input](../fields/text-input). Since text inputs are form components and all form components have a `columnSpan()` method, we can use it to specify how many columns the text input should fill. On devices smaller than the `sm` breakpoint, we want the text input to fill 1 column, which is default. On devices larger than the `sm` breakpoint, we want the text input to fill 2 columns. On devices larger than the `xl` breakpoint, we want the text input to fill 3 columns. On devices larger than the `2xl` breakpoint, we want the text input to fill 4 columns.
```php
use Filament\Forms\Components\TextInput;use Filament\Schema\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Section;
Section::make()
->columns([
+2 -1
View File
@@ -79,7 +79,8 @@ Tabs::make('Tabs')
The icon of the tab may be positioned before or after the label using the `iconPosition()` method:
```php
use Filament\Schema\Components\Tabs;use Filament\Support\Enums\IconPosition;
use Filament\Schema\Components\Tabs;
use Filament\Support\Enums\IconPosition;
Tabs::make('Tabs')
->tabs([
+9 -4
View File
@@ -35,7 +35,8 @@ Wizard::make([
You may use the `submitAction()` method to render submit button HTML or a view at the end of the wizard, on the last step. This provides a clearer UX than displaying a submit button below the wizard at all times:
```php
use Filament\Schema\Components\Wizard;use Illuminate\Support\HtmlString;
use Filament\Schema\Components\Wizard;
use Illuminate\Support\HtmlString;
Wizard::make([
// ...
@@ -49,7 +50,9 @@ Wizard::make([
Alternatively, you can use the built-in Filament button Blade component:
```php
use Filament\Schema\Components\Wizard;use Illuminate\Support\Facades\Blade;use Illuminate\Support\HtmlString;
use Filament\Schema\Components\Wizard;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\HtmlString;
Wizard::make([
// ...
@@ -183,7 +186,8 @@ Wizard\Step::make('Order')
Inside `afterValidation()` or `beforeValidation()`, you may throw `Filament\Support\Exceptions\Halt`, which will prevent the wizard from loading the next step:
```php
use Filament\Schema\Components\Wizard;use Filament\Support\Exceptions\Halt;
use Filament\Schema\Components\Wizard;
use Filament\Support\Exceptions\Halt;
Wizard\Step::make('Order')
->afterValidation(function () {
@@ -225,7 +229,8 @@ This component uses action objects for easy customization of buttons within it.
Here is an example of how you might customize an action:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Wizard;
use Filament\Actions\Action;
use Filament\Schema\Components\Wizard;
Wizard::make([
// ...
+7 -3
View File
@@ -41,7 +41,8 @@ Sections can have actions in their [header](#adding-actions-to-the-sections-head
You may add [actions](../actions) to the section's header using the `headerActions()` method:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Section;
use Filament\Actions\Action;
use Filament\Schema\Components\Section;
Section::make('Rate limiting')
->headerActions([
@@ -64,7 +65,8 @@ Section::make('Rate limiting')
In addition to [header actions](#adding-an-icon-to-the-sections-header), you may add [actions](../actions) to the section's footer using the `footerActions()` method:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Section;
use Filament\Actions\Action;
use Filament\Schema\Components\Section;
Section::make('Rate limiting')
->schema([
@@ -87,7 +89,9 @@ Section::make('Rate limiting')
Footer actions are aligned to the inline start by default. You may customize the alignment using the `footerActionsAlignment()` method:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Section;use Filament\Support\Enums\Alignment;
use Filament\Actions\Action;
use Filament\Schema\Components\Section;
use Filament\Support\Enums\Alignment;
Section::make('Rate limiting')
->schema([
+5 -1
View File
@@ -8,7 +8,11 @@ import AutoScreenshot from "@components/AutoScreenshot.astro"
The `Split` component allows you to define layouts with flexible widths, using flexbox.
```php
use Filament\Forms\Components\Textarea;use Filament\Forms\Components\TextInput;use Filament\Forms\Components\Toggle;use Filament\Schema\Components\Section;use Filament\Schema\Components\Split;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schema\Components\Section;
use Filament\Schema\Components\Split;
Split::make([
Section::make([
@@ -36,7 +36,8 @@ Placeholder::make('documentation')
By passing a closure to the `content()` method, you may dynamically generate placeholder content. You have access to any closure parameter explained in the [advanced closure customization](../advanced#closure-customization) documentation:
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Forms\Components\Placeholder;
use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\Placeholder;
Placeholder::make('total')
->content(function (Get $get): string {
+25 -10
View File
@@ -12,7 +12,8 @@ Filament's forms can use [Actions](../actions). They are buttons that can be add
Action objects inside a form component are instances of `Filament/Forms/Components/Actions/Action`. You must pass a unique name to the action's `make()` method, which is used to identify it amongst others internally within Filament. You can [customize the trigger button](../actions/trigger-button) of an action, and even [open a modal](../actions/modals) with little effort:
```php
use App\Actions\ResetStars;use Filament\Actions\Action;
use App\Actions\ResetStars;
use Filament\Actions\Action;
Action::make('resetStars')
->icon('heroicon-m-x-mark')
@@ -35,7 +36,9 @@ Certain fields support "affix actions", which are buttons that can be placed bef
To define an affix action, you can pass it to either `prefixAction()` or `suffixAction()`:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Utilities\Set;use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;
use Filament\Schema\Components\Utilities\Set;
use Filament\Forms\Components\TextInput;
TextInput::make('cost')
->prefix('€')
@@ -58,7 +61,8 @@ Notice `$set` and `$state` injected into the `action()` function in this example
You may pass multiple affix actions to a field by passing them in an array to either `prefixActions()` or `suffixActions()`. Either method can be used, or both at once, Filament will render all the registered actions in order:
```php
use Filament\Actions\Action;use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
TextInput::make('cost')
->prefix('€')
@@ -78,7 +82,9 @@ TextInput::make('cost')
All fields support "hint actions", which are rendered aside the field's [hint](fields/getting-started#adding-a-hint-next-to-the-label). To add a hint action to a field, you may pass it to `hintAction()`:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Utilities\Set;use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;
use Filament\Schema\Components\Utilities\Set;
use Filament\Forms\Components\TextInput;
TextInput::make('cost')
->prefix('€')
@@ -101,7 +107,8 @@ Notice `$set` and `$state` injected into the `action()` function in this example
You may pass multiple hint actions to a field by passing them in an array to `hintActions()`. Filament will render all the registered actions in order:
```php
use Filament\Actions\Action;use Filament\Forms\Components\TextInput;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
TextInput::make('cost')
->prefix('€')
@@ -117,7 +124,9 @@ TextInput::make('cost')
If you wish to render an action within a custom form component, `ViewField` object, or `View` component object, you may do so using the `registerActions()` method:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Utilities\Set;use Filament\Forms\Components\ViewField;
use Filament\Actions\Action;
use Filament\Schema\Components\Utilities\Set;
use Filament\Forms\Components\ViewField;
ViewField::make('rating')
->view('filament.forms.components.range-slider')
@@ -147,7 +156,10 @@ Now, to render the action in the view of the custom component, you need to call
You may use an `Actions` component to render a set of actions anywhere in the form, avoiding the need to register them to any particular component:
```php
use App\Actions\ResetStars;use App\Actions\Star;use Filament\Actions\Action;use Filament\Schema\Components\Actions;
use App\Actions\ResetStars;
use App\Actions\Star;
use Filament\Actions\Action;
use Filament\Schema\Components\Actions;
Actions::make([
Action::make('star')
@@ -187,7 +199,8 @@ Actions::make([
Independent form actions are aligned to the start of the component by default. You may change this by passing `Alignment::Center` or `Alignment::End` to `alignment()`:
```php
use Filament\Schema\Components\Actions;use Filament\Support\Enums\Alignment;
use Filament\Schema\Components\Actions;
use Filament\Support\Enums\Alignment;
Actions::make([
// ...
@@ -201,7 +214,8 @@ Actions::make([
Independent form actions are vertically aligned to the start of the component by default. You may change this by passing `Alignment::Center` or `Alignment::End` to `verticalAlignment()`:
```php
use Filament\Schema\Components\Actions;use Filament\Support\Enums\VerticalAlignment;
use Filament\Schema\Components\Actions;
use Filament\Support\Enums\VerticalAlignment;
Actions::make([
// ...
@@ -215,7 +229,8 @@ Actions::make([
If an action is attached to a form component, the `action()` function is able to [inject utilities](advanced#form-component-utility-injection) directly from that form component. For instance, you can inject [`$set`](advanced#injecting-a-function-to-set-the-state-of-another-field) and [`$state`](advanced#injecting-the-current-state-of-a-field):
```php
use Filament\Actions\Action;use Filament\Schema\Components\Utilities\Set;
use Filament\Actions\Action;
use Filament\Schema\Components\Utilities\Set;
Action::make('copyCostToPrice')
->icon('heroicon-m-clipboard')
+48 -18
View File
@@ -186,7 +186,9 @@ function (string $operation) {
The parameters are injected dynamically using reflection, so you are able to combine multiple parameters in any order:
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Schema\Components\Utilities\Set;use Livewire\Component as Livewire;
use Filament\Schema\Components\Utilities\Get;
use Filament\Schema\Components\Utilities\Set;
use Livewire\Component as Livewire;
function (Livewire $livewire, Get $get, Set $set) {
// ...
@@ -198,7 +200,8 @@ function (Livewire $livewire, Get $get, Set $set) {
You may inject anything from Laravel's container like normal, alongside utilities:
```php
use Filament\Schema\Components\Utilities\Set;use Illuminate\Http\Request;
use Filament\Schema\Components\Utilities\Set;
use Illuminate\Http\Request;
function (Request $request, Set $set) {
// ...
@@ -290,7 +293,9 @@ This section contains a collection of recipes for common tasks you may need to p
To conditionally hide or show a field, you can pass a function to the `hidden()` method, and return `true` or `false` depending on whether you want the field to be hidden or not. The function can [inject utilities](#form-component-utility-injection) as parameters, so you can do things like check the value of another field:
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Forms\Components\Checkbox;use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\TextInput;
Checkbox::make('is_company')
->live()
@@ -304,7 +309,9 @@ In this example, the `is_company` checkbox is [`live()`](#the-basics-of-reactivi
Alternatively, you can use the `visible()` method to show a field conditionally. It does the exact inverse of `hidden()`, and could be used if you prefer the clarity of the code when written this way:
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Forms\Components\Checkbox;use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\TextInput;
Checkbox::make('is_company')
->live()
@@ -318,7 +325,8 @@ TextInput::make('company_name')
To conditionally make a field required, you can pass a function to the `required()` method, and return `true` or `false` depending on whether you want the field to be required or not. The function can [inject utilities](#form-component-utility-injection) as parameters, so you can do things like check the value of another field:
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\TextInput;
TextInput::make('company_name')
->live(onBlur: true)
@@ -336,7 +344,9 @@ Using a function is able to make any other [validation rule](validation) dynamic
To generate a slug from a title while the user is typing, you can use the [`afterStateUpdated()` method](#field-updates) on the title field to [`$set()`](#injecting-a-function-to-set-the-state-of-another-field) the value of the slug field:
```php
use Filament\Schema\Components\Utilities\Set;use Filament\Forms\Components\TextInput;use Illuminate\Support\Str;
use Filament\Schema\Components\Utilities\Set;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Str;
TextInput::make('title')
->live()
@@ -350,7 +360,10 @@ In this example, the `title` field is [`live()`](#the-basics-of-reactivity). Thi
One thing to note is that the user may customize the slug manually, and we don't want to overwrite their changes if the title changes. To prevent this, we can use the old version of the title to work out if the user has modified it themselves. To access the old version of the title, you can inject `$old`, and to get the current value of the slug before it gets changed, we can use the [`$get()` utility](#injecting-the-state-of-another-field):
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Schema\Components\Utilities\Set;use Filament\Forms\Components\TextInput;use Illuminate\Support\Str;
use Filament\Schema\Components\Utilities\Get;
use Filament\Schema\Components\Utilities\Set;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Str;
TextInput::make('title')
->live()
@@ -370,7 +383,8 @@ TextInput::make('slug')
To dynamically update the options of a [select field](fields/select) based on the value of another field, you can pass a function to the `options()` method of the select field. The function can [inject utilities](#form-component-utility-injection) as parameters, so you can do things like check the value of another field using the [`$get()` utility](#injecting-the-current-state-of-a-field):
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Forms\Components\Select;
use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\Select;
Select::make('category')
->options([
@@ -403,7 +417,9 @@ In this example, the `category` field is [`live()`](#the-basics-of-reactivity).
You could adapt this example to use options loaded from an Eloquent model or other data source, by querying within the function:
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Forms\Components\Select;use Illuminate\Support\Collection;
use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\Select;
use Illuminate\Support\Collection;
Select::make('category')
->options(Category::query()->pluck('name', 'id'))
@@ -420,7 +436,11 @@ Select::make('sub_category')
You may wish to render a different set of fields based on the value of a field, like a select. To do this, you can pass a function to the `schema()` method of any [layout component](layout/getting-started), which checks the value of the field and returns a different schema based on that value. Also, you will need a way to initialise the new fields in the dynamic schema when they are first loaded.
```php
use Filament\Forms\Components\FileUpload;use Filament\Forms\Components\Select;use Filament\Forms\Components\TextInput;use Filament\Schema\Components\Grid;use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Grid;
use Filament\Schema\Components\Utilities\Get;
Select::make('type')
->options([
@@ -512,7 +532,10 @@ TextInput::make('password')
As well as being able to give structure to fields, [layout components](layout/getting-started) are also able to "teleport" their nested fields into a relationship. Filament will handle loading data from a `HasOne`, `BelongsTo` or `MorphOne` Eloquent relationship, and then it will save the data back to the same relationship. To set this behavior up, you can use the `relationship()` method on any layout component:
```php
use Filament\Forms\Components\FileUpload;use Filament\Forms\Components\Textarea;use Filament\Forms\Components\TextInput;use Filament\Schema\Components\Fieldset;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Fieldset;
Fieldset::make('Metadata')
->relationship('metadata')
@@ -528,7 +551,8 @@ In this example, the `title`, `description` and `image` are automatically loaded
This functionality is not just limited to fieldsets - you can use it with any layout component. For example, you could use a `Group` component which has no styling associated with it:
```php
use Filament\Forms\Components\TextInput;use Filament\Schema\Components\Group;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Group;
Group::make()
->relationship('customer')
@@ -554,7 +578,8 @@ It is worth noting that if you have an observer on your form model, then you may
Sometimes, saving the related record may be optional. If the user fills out the customer fields, then the customer will be created / updated. Otherwise, the customer will not be created, or will be deleted if it already exists. To do this, you can pass a `condition` function as an argument to `relationship()`, which can use the `$state` of the related form to determine whether the relationship should be saved or not:
```php
use Filament\Forms\Components\TextInput;use Filament\Schema\Components\Group;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Group;
Group::make()
->relationship(
@@ -578,7 +603,8 @@ In this example, the customer's name is not `required()`, and the email address
You may insert a Livewire component directly into a form:
```php
use App\Livewire\Foo;use Filament\Schema\Components\Livewire;
use App\Livewire\Foo;
use Filament\Schema\Components\Livewire;
Livewire::make(Foo::class)
```
@@ -586,7 +612,8 @@ Livewire::make(Foo::class)
If you are rendering multiple of the same Livewire component, please make sure to pass a unique `key()` to each:
```php
use App\Livewire\Foo;use Filament\Schema\Components\Livewire;
use App\Livewire\Foo;
use Filament\Schema\Components\Livewire;
Livewire::make(Foo::class)
->key('foo-first')
@@ -603,7 +630,8 @@ Livewire::make(Foo::class)
You can pass an array of parameters to a Livewire component:
```php
use App\Livewire\Foo;use Filament\Schema\Components\Livewire;
use App\Livewire\Foo;
use Filament\Schema\Components\Livewire;
Livewire::make(Foo::class, ['bar' => 'baz'])
```
@@ -652,7 +680,8 @@ class Foo extends Component
Please be aware that when the record has not yet been created, it will be `null`. If you'd like to hide the Livewire component when the record is `null`, you can use the `hidden()` method:
```php
use Filament\Schema\Components\Livewire;use Illuminate\Database\Eloquent\Model;
use Filament\Schema\Components\Livewire;
use Illuminate\Database\Eloquent\Model;
Livewire::make(Foo::class)
->hidden(fn (?Model $record): bool => $record === null)
@@ -663,7 +692,8 @@ Livewire::make(Foo::class)
You may allow the component to [lazily load](https://livewire.laravel.com/docs/lazy#rendering-placeholder-html) using the `lazy()` method:
```php
use App\Livewire\Foo;use Filament\Schema\Components\Livewire;
use App\Livewire\Foo;
use Filament\Schema\Components\Livewire;
Livewire::make(Foo::class)->lazy()
```
@@ -40,7 +40,13 @@ There are 5 main tasks when adding a form to a Livewire component class. Each on
namespace App\Livewire;
use Filament\Forms\Components\MarkdownEditor;use Filament\Forms\Components\TextInput;use Filament\Forms\Concerns\InteractsWithForms;use Filament\Forms\Contracts\HasForms;use Filament\Schema\Schema;use Illuminate\Contracts\View\View;use Livewire\Component;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Schema\Schema;
use Illuminate\Contracts\View\View;
use Livewire\Component;
class CreatePost extends Component implements HasForms
{
@@ -156,7 +162,8 @@ public function form(Schema $form): Schema
In some cases, the form's model is not available until the form has been submitted. For example, in a Create Post form, the post does not exist until the form has been submitted. Therefore, you can't pass it in to `$form->model()`. However, you can pass a model class instead:
```php
use App\Models\Post;use Filament\Schema\Schema;
use App\Models\Post;
use Filament\Schema\Schema;
public function form(Schema $form): Schema
{
@@ -188,7 +195,9 @@ public function create(): void
In all of our previous examples, we've been saving the form's data to the public `$data` property on the Livewire component. However, you can save the data to individual properties instead. For example, if you have a form with a `title` field, you can save the form's data to the `$title` property instead. To do this, don't pass a `statePath()` to the form at all. Ensure that all of your fields have their own **public** properties on the class.
```php
use Filament\Forms\Components\MarkdownEditor;use Filament\Forms\Components\TextInput;use Filament\Schema\Schema;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Schema;
public ?string $title = null;
@@ -223,7 +232,9 @@ protected function getForms(): array
Each of these forms can now be defined within the Livewire component, using a method with the same name:
```php
use Filament\Forms\Components\MarkdownEditor;use Filament\Forms\Components\TextInput;use Filament\Schema\Schema;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Schema;
public function editPostForm(Schema $form): Schema
{
@@ -55,7 +55,8 @@ You can learn more about columns and spans in the [layout documentation](layout/
The Infolist Builder allows you to use [layout components](layout/getting-started#available-layout-components) inside the schema array to control how entries are displayed. `Section` is a layout component, and it allows you to add a heading and description to a set of entries. It can also allow entries inside it to collapse, which saves space in long infolists.
```php
use Filament\Infolists\Components\TextEntry;use Filament\Schema\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Filament\Schema\Components\Section;
[
TextEntry::make('title'),
@@ -74,7 +75,9 @@ use Filament\Infolists\Components\TextEntry;use Filament\Schema\Components\Secti
In this example, you can see how the `Section` component has its own `schema()` method. You can use this to nest other entries and layout components inside:
```php
use Filament\Infolists\Components\ImageEntry;use Filament\Infolists\Components\TextEntry;use Filament\Schema\Components\Section;
use Filament\Infolists\Components\ImageEntry;
use Filament\Infolists\Components\TextEntry;
use Filament\Schema\Components\Section;
Section::make('Media')
->description('Images used in the page layout.')
+4 -2
View File
@@ -32,7 +32,8 @@ We pass an array to `columns()` as we want to specify different numbers of colum
Inside the section, we have a [text entry](../entries/text). Since text entries are infolist components and all form components have a `columnSpan()` method, we can use it to specify how many columns the text entry should fill. On devices smaller than the `sm` breakpoint, we want the text entry to fill 1 column, which is default. On devices larger than the `sm` breakpoint, we want the text entry to fill 2 columns. On devices larger than the `xl` breakpoint, we want the text entry to fill 3 columns. On devices larger than the `2xl` breakpoint, we want the text entry to fill 4 columns.
```php
use Filament\Infolists\Components\TextEntry;use Filament\Schema\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Filament\Schema\Components\Section;
Section::make()
->columns([
@@ -79,7 +80,8 @@ If you want to start a component in a grid at a specific column, you can use the
- `columnStart(['md' => 2, 'xl' => 4])` will make the component start at column 2 on medium devices, and at column 4 on extra large devices. The default breakpoint for smaller devices uses 1 column, unless you use a `default` array key.
```php
use Filament\Infolists\Components\TextEntry;use Filament\Schema\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Filament\Schema\Components\Section;
Section::make()
->columns([
+2 -1
View File
@@ -79,7 +79,8 @@ Tabs::make('Tabs')
The icon of the tab may be positioned before or after the label using the `iconPosition()` method:
```php
use Filament\Schema\Components\Tabs;use Filament\Support\Enums\IconPosition;
use Filament\Schema\Components\Tabs;
use Filament\Support\Enums\IconPosition;
Tabs::make('Tabs')
->tabs([
@@ -41,7 +41,8 @@ Sections can have actions in their [header](#adding-actions-to-the-sections-head
You may add [actions](../actions) to the section's header using the `headerActions()` method:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Section;
use Filament\Actions\Action;
use Filament\Schema\Components\Section;
Section::make('Rate limiting')
->headerActions([
@@ -64,7 +65,8 @@ Section::make('Rate limiting')
In addition to [header actions](#adding-an-icon-to-the-sections-header), you may add [actions](../actions) to the section's footer using the `footerActions()` method:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Section;
use Filament\Actions\Action;
use Filament\Schema\Components\Section;
Section::make('Rate limiting')
->footerActions([
@@ -87,7 +89,9 @@ Section::make('Rate limiting')
Footer actions are aligned to the inline start by default. You may customize the alignment using the `footerActionsAlignment()` method:
```php
use Filament\Actions\Action;use Filament\Schema\Components\Section;use Filament\Support\Enums\Alignment;
use Filament\Actions\Action;
use Filament\Schema\Components\Section;
use Filament\Support\Enums\Alignment;
Section::make('Rate limiting')
->footerActions([
@@ -8,7 +8,10 @@ import AutoScreenshot from "@components/AutoScreenshot.astro"
The `Split` component allows you to define layouts with flexible widths, using flexbox.
```php
use Filament\Infolists\Components\TextEntry;use Filament\Schema\Components\Section;use Filament\Schema\Components\Split;use Filament\Support\Enums\FontWeight;
use Filament\Infolists\Components\TextEntry;
use Filament\Schema\Components\Section;
use Filament\Schema\Components\Split;
use Filament\Support\Enums\FontWeight;
Split::make([
Section::make([
+25 -9
View File
@@ -12,7 +12,8 @@ Filament's infolists can use [Actions](../actions). They are buttons that can be
Action objects inside an infolist component are instances of `Filament/Infolists/Components/Actions/Action`. You must pass a unique name to the action's `make()` method, which is used to identify it amongst others internally within Filament. You can [customize the trigger button](../actions/trigger-button) of an action, and even [open a modal](../actions/modals) with little effort:
```php
use App\Actions\ResetStars;use Filament\Actions\Action;
use App\Actions\ResetStars;
use Filament\Actions\Action;
Action::make('resetStars')
->icon('heroicon-m-x-mark')
@@ -32,7 +33,9 @@ Certain entries support "affix actions", which are buttons that can be placed be
To define an affix action, you can pass it to either `prefixAction()` or `suffixAction()`:
```php
use App\Models\Product;use Filament\Actions\Action;use Filament\Infolists\Components\TextEntry;
use App\Models\Product;
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
TextEntry::make('cost')
->prefix('€')
@@ -54,7 +57,8 @@ TextEntry::make('cost')
You may pass multiple affix actions to an entry by passing them in an array to either `prefixActions()` or `suffixActions()`. Either method can be used, or both at once, Filament will render all the registered actions in order:
```php
use Filament\Actions\Action;use Filament\Infolists\Components\TextEntry;
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
TextEntry::make('cost')
->prefix('€')
@@ -74,7 +78,9 @@ TextEntry::make('cost')
All entries support "hint actions", which are rendered aside the entry's [hint](entries/getting-started#adding-a-hint-next-to-the-label). To add a hint action to a entry, you may pass it to `hintAction()`:
```php
use App\Models\Product;use Filament\Actions\Action;use Filament\Infolists\Components\TextEntry;
use App\Models\Product;
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
TextEntry::make('cost')
->prefix('€')
@@ -96,7 +102,8 @@ TextEntry::make('cost')
You may pass multiple hint actions to a entry by passing them in an array to `hintActions()`. Filament will render all the registered actions in order:
```php
use Filament\Actions\Action;use Filament\Infolists\Components\TextEntry;
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
TextEntry::make('cost')
->prefix('€')
@@ -112,7 +119,11 @@ TextEntry::make('cost')
If you wish to render an action within a custom infolist component, `ViewEntry` object, or `View` component object, you may do so using the `registerActions()` method:
```php
use App\Models\Post;use Filament\Actions\Action;use Filament\Forms\Components\TextInput;use Filament\Infolists\Components\ViewEntry;use Filament\Infolists\Set;
use App\Models\Post;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Infolists\Components\ViewEntry;
use Filament\Infolists\Set;
ViewEntry::make('status')
->view('filament.infolists.entries.status-switcher')
@@ -144,7 +155,10 @@ Now, to render the action in the view of the custom component, you need to call
You may use an `Actions` component to render a set of actions anywhere in the form, avoiding the need to register them to any particular component:
```php
use App\Actions\ResetStars;use App\Actions\Star;use Filament\Actions\Action;use Filament\Schema\Components\Actions;
use App\Actions\ResetStars;
use App\Actions\Star;
use Filament\Actions\Action;
use Filament\Schema\Components\Actions;
Actions::make([
Action::make('star')
@@ -184,7 +198,8 @@ Actions::make([
Independent infolist actions are aligned to the start of the component by default. You may change this by passing `Alignment::Center` or `Alignment::End` to `alignment()`:
```php
use Filament\Schema\Components\Actions;use Filament\Support\Enums\Alignment;
use Filament\Schema\Components\Actions;
use Filament\Support\Enums\Alignment;
Actions::make([
// ...
@@ -198,7 +213,8 @@ Actions::make([
Independent infolist actions are vertically aligned to the start of the component by default. You may change this by passing `Alignment::Center` or `Alignment::End` to `verticalAlignment()`:
```php
use Filament\Schema\Components\Actions;use Filament\Support\Enums\VerticalAlignment;
use Filament\Schema\Components\Actions;
use Filament\Support\Enums\VerticalAlignment;
Actions::make([
// ...
+8 -4
View File
@@ -7,7 +7,8 @@ title: Advanced infolists
You may insert a Livewire component directly into an infolist:
```php
use App\Livewire\Foo;use Filament\Schema\Components\Livewire;
use App\Livewire\Foo;
use Filament\Schema\Components\Livewire;
Livewire::make(Foo::class)
```
@@ -15,7 +16,8 @@ Livewire::make(Foo::class)
If you are rendering multiple of the same Livewire component, please make sure to pass a unique `key()` to each:
```php
use App\Livewire\Foo;use Filament\Schema\Components\Livewire;
use App\Livewire\Foo;
use Filament\Schema\Components\Livewire;
Livewire::make(Foo::class)
->key('foo-first')
@@ -32,7 +34,8 @@ Livewire::make(Foo::class)
You can pass an array of parameters to a Livewire component:
```php
use App\Livewire\Foo;use Filament\Schema\Components\Livewire;
use App\Livewire\Foo;
use Filament\Schema\Components\Livewire;
Livewire::make(Foo::class, ['bar' => 'baz'])
```
@@ -83,7 +86,8 @@ class Foo extends Component
You may allow the component to [lazily load](https://livewire.laravel.com/docs/lazy#rendering-placeholder-html) using the `lazy()` method:
```php
use App\Livewire\Foo;use Filament\Schema\Components\Livewire;
use App\Livewire\Foo;
use Filament\Schema\Components\Livewire;
Livewire::make(Foo::class)->lazy()
```
@@ -73,7 +73,8 @@ You can pass data to the infolist in two ways:
Either pass an Eloquent model instance to the `record()` method of the infolist, to automatically map all the model attributes and relationships to the entries in the infolist's schema:
```php
use Filament\Infolists\Components\TextEntry;use Filament\Schema\Schema;
use Filament\Infolists\Components\TextEntry;
use Filament\Schema\Schema;
public function productInfolist(Schema $infolist): Schema
{
@@ -90,7 +91,8 @@ public function productInfolist(Schema $infolist): Schema
Alternatively, you can pass an array of data to the `state()` method of the infolist, to manually map the data to the entries in the infolist's schema:
```php
use Filament\Infolists\Components\TextEntry;use Filament\Schema\Schema;
use Filament\Infolists\Components\TextEntry;
use Filament\Schema\Schema;
public function productInfolist(Schema $infolist): Schema
{
@@ -228,7 +228,8 @@ new FilamentNotification()
Notifications support [Actions](../actions/trigger-button), which are buttons that render below the content of the notification. They can open a URL or dispatch a Livewire event. Actions can be defined as follows:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
Notification::make()
->title('Saved successfully')
@@ -268,7 +269,8 @@ You can learn more about how to style action buttons [here](../actions/trigger-b
You can open a URL, optionally in a new tab, when clicking on an action:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
Notification::make()
->title('Saved successfully')
@@ -307,7 +309,8 @@ new FilamentNotification()
Sometimes you want to execute additional code when a notification action is clicked. This can be achieved by setting a Livewire event which should be dispatched on clicking the action. You may optionally pass an array of data, which will be available as parameters in the event listener on your Livewire component:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
Notification::make()
->title('Saved successfully')
@@ -372,7 +375,8 @@ new FilamentNotificationAction('undo')
After opening a URL or dispatching an event from your action, you may want to close the notification right away:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
Notification::make()
->title('Saved successfully')
@@ -162,7 +162,8 @@ event(new DatabaseNotificationsSent($recipient));
There is a button at the top of the modal to mark all notifications as read at once. You may also add [Actions](sending-notifications#adding-actions-to-notifications) to notifications, which you can use to mark individual notifications as read. To do this, use the `markAsRead()` method on the action:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
Notification::make()
->title('Saved successfully')
@@ -179,7 +180,8 @@ Notification::make()
Alternatively, you may use the `markAsUnread()` method to mark a notification as unread:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
Notification::make()
->title('Saved successfully')
+16 -7
View File
@@ -157,7 +157,8 @@ If you open the `PatientResource.php` file, there's a `form()` method with an em
Filament bundles a large selection of [form fields](../forms/fields/getting-started#available-fields). Let's start with a simple [text input field](../forms/fields/text-input):
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public static function form(Schema $form): Schema
{
@@ -187,7 +188,8 @@ Attempt to submit the form to create a new patient without a name and observe th
Let's add a second field for the type of patient: a choice between a cat, dog, or rabbit. Since there's a fixed set of options to choose from, a [select](../forms/fields/select) field works well:
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public static function form(Schema $form): Schema
{
@@ -227,7 +229,8 @@ Forms\Components\Select::make('type')
Let's add a [date picker field](../forms/fields/date-time-picker) for the `date_of_birth` column along with the validation (the date of birth is required and the date should be no later than the current day).
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public static function form(Schema $form): Schema
{
@@ -255,7 +258,8 @@ public static function form(Schema $form): Schema
We should also add an owner when creating a new patient. Since we added a `BelongsTo` relationship in the Patient model (associating it to the related `Owner` model), we can use the **[`relationship()` method](../forms/fields/select#integrating-with-an-eloquent-relationship)** from the select field to load a list of owners to choose from:
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public static function form(Schema $form): Schema
{
@@ -474,7 +478,10 @@ public static function getRelations(): array
The `TreatmentsRelationManager.php` file contains a class that is prepopulated with a form and table using the parameters from the `make:filament-relation-manager` artisan command. You can customize the fields and columns in the relation manager similar to how you would in a resource:
```php
use Filament\Forms;use Filament\Schema\Schema;use Filament\Tables;use Filament\Tables\Table;
use Filament\Forms;
use Filament\Schema\Schema;
use Filament\Tables;
use Filament\Tables\Table;
public function form(Schema $form): Schema
{
@@ -513,7 +520,8 @@ Forms\Components\TextInput::make('description')
Let's add the `notes` field, which can be used to add more details about the treatment. We can use a [textarea](../forms/fields/textarea) field with a `columnSpan('full')`:
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public function form(Schema $form): Schema
{
@@ -535,7 +543,8 @@ public function form(Schema $form): Schema
Let's add a `price` field for the treatment. We can use a text input with some customizations to make it suitable for currency input. It should be `numeric()`, which adds validation and changes the keyboard layout on mobile devices. Add your preferred currency prefix using the `prefix()` method; for example, `prefix('€')` will add a `€` before the input without impacting the saved output value:
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public function form(Schema $form): Schema
{
@@ -124,7 +124,8 @@ This is required for features like [global search](global-search) to work.
Resource classes contain a `form()` method that is used to build the forms on the [Create](creating-records) and [Edit](editing-records) pages:
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public static function form(Schema $form): Schema
{
@@ -179,7 +180,9 @@ Forms\Components\TextInput::make('password')
Resource classes contain a `table()` method that is used to build the table on the [List page](listing-records):
```php
use Filament\Tables;use Filament\Tables\Table;use Illuminate\Database\Eloquent\Builder;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
public static function table(Table $table): Table
{
@@ -408,7 +411,8 @@ This can be especially useful if you are using [simple resources](#simple-modal-
To generate a URL for an action in the resource's table, you should pass the `tableAction` and `tableActionRecord` as URL parameters:
```php
use App\Filament\Resources\CustomerResource;use Filament\Actions\EditAction;
use App\Filament\Resources\CustomerResource;
use Filament\Actions\EditAction;
CustomerResource::getUrl(parameters: [
'tableAction' => EditAction::getDefaultName(),
@@ -198,7 +198,8 @@ Alternatively, if you're creating records in a modal action, check out the [Acti
At any time, you may call `$this->halt()` from inside a lifecycle hook or mutation method, which will halt the entire creation process:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
protected function beforeCreate(): void
{
@@ -256,7 +257,10 @@ class CreateCategory extends CreateRecord
Inside the `getSteps()` array, return your [wizard steps](../../forms/layout/wizard):
```php
use Filament\Forms\Components\MarkdownEditor;use Filament\Forms\Components\TextInput;use Filament\Forms\Components\Toggle;use Filament\Schema\Components\Wizard\Step;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schema\Components\Wizard\Step;
protected function getSteps(): array
{
@@ -308,7 +312,9 @@ public function hasSkippableSteps(): bool
If you'd like to reduce the amount of repetition between the resource form and wizard steps, it's a good idea to extract public static resource functions for your fields, where you can easily retrieve an instance of a field from the resource or the wizard:
```php
use Filament\Forms;use Filament\Resources\Resource;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Resources\Resource;
use Filament\Schema\Schema;
class CategoryResource extends Resource
{
@@ -183,7 +183,10 @@ Alternatively, if you're editing records in a modal action, check out the [Actio
You may want to allow the user to save a part of the form independently of the rest of the form. One way to do this is with a [section action in the header or footer](../../forms/layout/section#adding-actions-to-the-sections-header-or-footer). From the `action()` method, you can call `saveFormComponentOnly()`, passing in the `Section` component that you want to save:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;use Filament\Resources\Pages\EditRecord;use Filament\Schema\Components\Section;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
use Filament\Schema\Components\Section;
Section::make('Rate limiting')
->schema([
@@ -211,7 +214,8 @@ The `$operation` helper is available, to ensure that the action is only visible
At any time, you may call `$this->halt()` from inside a lifecycle hook or mutation method, which will halt the entire saving process:
```php
use Filament\Actions\Action;use Filament\Notifications\Notification;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
protected function beforeSave(): void
{
@@ -23,7 +23,8 @@ php artisan make:filament-resource User --view
By default, the View page will display a disabled form with the record's data. If you preferred to display the record's data in an "infolist", you can define an `infolist()` method on the resource class:
```php
use Filament\Infolists;use Filament\Schema\Schema;
use Filament\Infolists;
use Filament\Schema\Schema;
public static function infolist(Schema $infolist): Schema
{
@@ -19,7 +19,10 @@ Alternatively, you may add soft deleting functionality to an existing resource.
Firstly, you must update the resource:
```php
use Filament\Tables;use Filament\Tables\Table;use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
public static function table(Table $table): Table
{
@@ -36,7 +36,10 @@ From a UX perspective, this solution is only suitable if your related model only
All layout form components ([Grid](../../forms/layout/grid#grid-component), [Section](../../forms/layout/section), [Fieldset](../../forms/layout/fieldset), etc.) have a [`relationship()` method](../../forms/advanced#saving-data-to-relationships). When you use this, all fields within that layout are saved to the related model instead of the owner's model:
```php
use Filament\Forms\Components\FileUpload;use Filament\Forms\Components\Textarea;use Filament\Forms\Components\TextInput;use Filament\Schema\Components\Fieldset;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Components\Fieldset;
Fieldset::make('Metadata')
->relationship('metadata')
@@ -73,7 +76,10 @@ php artisan make:filament-relation-manager CategoryResource posts title
This will create a `CategoryResource/RelationManagers/PostsRelationManager.php` file. This contains a class where you are able to define a [form](getting-started#resource-forms) and [table](getting-started#resource-tables) for your relation manager:
```php
use Filament\Forms;use Filament\Schema\Schema;use Filament\Tables;use Filament\Tables\Table;
use Filament\Forms;
use Filament\Schema\Schema;
use Filament\Tables;
use Filament\Tables\Table;
public function form(Schema $form): Schema
{
@@ -192,7 +198,8 @@ Please ensure that any pivot attributes are listed in the `withPivot()` method o
For `BelongsToMany` and `MorphToMany` relationships, you may also add pivot table attributes. For example, if you have a `TeamsRelationManager` for your `UserResource`, and you want to add the `role` pivot attribute to the create form, you can use:
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public function form(Schema $form): Schema
{
@@ -218,7 +225,8 @@ To learn how to customize the `CreateAction`, including mutating the form data,
For `BelongsToMany` and `MorphToMany` relationships, you may also edit pivot table attributes. For example, if you have a `TeamsRelationManager` for your `UserResource`, and you want to add the `role` pivot attribute to the edit form, you can use:
```php
use Filament\Forms;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Schema\Schema;
public function form(Schema $form): Schema
{
@@ -291,7 +299,8 @@ AttachAction::make()
When you attach record with the `Attach` button, you may wish to define a custom form to add pivot attributes to the relationship:
```php
use Filament\Actions\AttachAction;use Filament\Forms;
use Filament\Actions\AttachAction;
use Filament\Forms;
AttachAction::make()
->form(fn (AttachAction $action): array => [
@@ -309,7 +318,8 @@ Please ensure that any pivot attributes are listed in the `withPivot()` method o
You may want to scope the options available to `AttachAction`:
```php
use Filament\Actions\AttachAction;use Illuminate\Database\Eloquent\Builder;
use Filament\Actions\AttachAction;
use Illuminate\Database\Eloquent\Builder;
AttachAction::make()
->recordSelectOptionsQuery(fn (Builder $query) => $query->whereBelongsTo(auth()->user()))
@@ -342,7 +352,8 @@ AttachAction::make()
You may customize the select field object that is used during attachment by passing a function to the `recordSelect()` method:
```php
use Filament\Actions\AttachAction;use Filament\Forms\Components\Select;
use Filament\Actions\AttachAction;
use Filament\Forms\Components\Select;
AttachAction::make()
->recordSelect(
@@ -420,7 +431,8 @@ AssociateAction::make()
You may want to scope the options available to `AssociateAction`:
```php
use Filament\Actions\AssociateAction;use Illuminate\Database\Eloquent\Builder;
use Filament\Actions\AssociateAction;
use Illuminate\Database\Eloquent\Builder;
AssociateAction::make()
->recordSelectOptionsQuery(fn (Builder $query) => $query->whereBelongsTo(auth()->user()))
@@ -453,7 +465,8 @@ AssociateAction::make()
You may customize the select field object that is used during association by passing a function to the `recordSelect()` method:
```php
use Filament\Actions\AssociateAction;use Filament\Forms\Components\Select;
use Filament\Actions\AssociateAction;
use Filament\Forms\Components\Select;
AssociateAction::make()
->recordSelect(
@@ -498,7 +511,10 @@ php artisan make:filament-relation-manager CategoryResource posts title --soft-d
Alternatively, you may add soft deleting functionality to an existing relation manager:
```php
use Filament\Tables;use Filament\Tables\Table;use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
public function table(Table $table): Table
{
@@ -579,7 +595,9 @@ $this->getOwnerRecord()
However, if you're inside a `static` method like `form()` or `table()`, `$this` isn't accessible. So, you may [use a callback](../../forms/advanced#form-component-utility-injection) to access the `$livewire` instance:
```php
use Filament\Forms;use Filament\Resources\RelationManagers\RelationManager;use Filament\Schema\Schema;
use Filament\Forms;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schema\Schema;
public function form(Schema $form): Schema
{
@@ -760,7 +778,9 @@ RelationGroup::make('Contacts', [
You may decide that you want a resource's form and table to be identical to a relation manager's, and subsequently want to reuse the code you previously wrote. This is easy, by calling the `form()` and `table()` methods of the resource from the relation manager:
```php
use App\Filament\Resources\Blog\PostResource;use Filament\Schema\Schema;use Filament\Tables\Table;
use App\Filament\Resources\Blog\PostResource;
use Filament\Schema\Schema;
use Filament\Tables\Table;
public function form(Schema $form): Schema
{
@@ -829,7 +849,8 @@ public function table(Table $table): Table
It is probably also useful to provide extra configuration on the relation manager if you wanted to add a header action to [create](#creating-related-records), [attach](#attaching-and-detaching-records), or [associate](#associating-and-dissociating-records) records in the relation manager:
```php
use App\Filament\Resources\Blog\PostResource;use Filament\Tables\Table;
use App\Filament\Resources\Blog\PostResource;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -924,7 +945,8 @@ public function table(Table $table): Table
If you're using `recordTitle()`, and you have an [associate action](#associating-and-dissociating-records) or [attach action](#attaching-and-detaching-records), you will also want to specify search columns for those actions:
```php
use Filament\Actions\AssociateAction;use Filament\Actions\AttachAction;
use Filament\Actions\AssociateAction;
use Filament\Actions\AttachAction;
AssociateAction::make()
->recordSelectSearchColumns(['title', 'id']);
+9 -2
View File
@@ -118,7 +118,11 @@ Firstly, you must [replace the original Dashboard page](#customizing-the-dashboa
Now, in your new `app/Filament/Pages/Dashboard.php` file, you may add the `HasFiltersForm` trait, and add the `filtersForm()` method to return form components:
```php
use Filament\Forms\Components\DatePicker;use Filament\Pages\Dashboard as BaseDashboard;use Filament\Pages\Dashboard\Concerns\HasFiltersForm;use Filament\Schema\Components\Section;use Filament\Schema\Schema;
use Filament\Forms\Components\DatePicker;
use Filament\Pages\Dashboard as BaseDashboard;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Schema\Components\Section;
use Filament\Schema\Schema;
class Dashboard extends BaseDashboard
{
@@ -185,7 +189,10 @@ Alternatively, you can swap out the filters form for an action modal, that can b
To use an action modal instead of a filters form, you can use the `HasFiltersAction` trait instead of `HasFiltersForm`. Then, register the `FilterAction` class as an action in `getHeaderActions()`:
```php
use Filament\Forms\Components\DatePicker;use Filament\Pages\Dashboard as BaseDashboard;use Filament\Pages\Dashboard\Actions\FilterAction;use Filament\Pages\Dashboard\Concerns\HasFiltersAction;
use Filament\Forms\Components\DatePicker;
use Filament\Pages\Dashboard as BaseDashboard;
use Filament\Pages\Dashboard\Actions\FilterAction;
use Filament\Pages\Dashboard\Concerns\HasFiltersAction;
class Dashboard extends BaseDashboard
{
+4 -2
View File
@@ -246,7 +246,8 @@ To register new navigation items, you can use the [configuration](configuration)
```php
use Filament\Navigation\NavigationItem;
use Filament\Pages\Dashboard;
use Filament\Panel;use function Filament\Support\original_request;
use Filament\Panel;
use function Filament\Support\original_request;
public function panel(Panel $panel): Panel
{
@@ -328,7 +329,8 @@ use App\Filament\Resources\UserResource;
use Filament\Navigation\NavigationBuilder;
use Filament\Navigation\NavigationItem;
use Filament\Pages\Dashboard;
use Filament\Panel;use function Filament\Support\original_request;
use Filament\Panel;
use function Filament\Support\original_request;
public function panel(Panel $panel): Panel
{
+3 -1
View File
@@ -203,7 +203,9 @@ In this example, we will customize the profile page. We need to create a new PHP
namespace App\Filament\Pages\Auth;
use Filament\Forms\Components\TextInput;use Filament\Pages\Auth\EditProfile as BaseEditProfile;use Filament\Schema\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Auth\EditProfile as BaseEditProfile;
use Filament\Schema\Schema;
class EditProfile extends BaseEditProfile
{
+7 -2
View File
@@ -119,7 +119,10 @@ To set up a registration page, you'll need to create a new page class that exten
```php
namespace App\Filament\Pages\Tenancy;
use App\Models\Team;use Filament\Forms\Components\TextInput;use Filament\Pages\Tenancy\RegisterTenant;use Filament\Schema\Schema;
use App\Models\Team;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Tenancy\RegisterTenant;
use Filament\Schema\Schema;
class RegisterTeam extends RegisterTenant
{
@@ -177,7 +180,9 @@ To set up a profile page, you'll need to create a new page class that extends `F
```php
namespace App\Filament\Pages\Tenancy;
use Filament\Forms\Components\TextInput;use Filament\Pages\Tenancy\EditTenantProfile;use Filament\Schema\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Tenancy\EditTenantProfile;
use Filament\Schema\Schema;
class EditTeamProfile extends EditTenantProfile
{
@@ -159,7 +159,9 @@ It's possible to target a file upload component to only handle a certain subset
For example, you could scope the field to only handle media that has certain custom properties:
```php
use Filament\Schema\Components\Utilities\Get;use Filament\Forms\Components\SpatieMediaLibraryFileUpload;use Illuminate\Support\Collection;
use Filament\Schema\Components\Utilities\Get;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Illuminate\Support\Collection;
SpatieMediaLibraryFileUpload::make('images')
->customProperties(fn (Get $get): array => [
@@ -37,7 +37,9 @@ You must define a form schema to interact with your settings class inside the `f
Since the [Form Builder](https://filamentphp.com/docs/forms) is installed in the Panel Builder by default, you may use any form [fields](https://filamentphp.com/docs/forms/fields) or [layout components](https://filamentphp.com/docs/forms/layout) you like:
```php
use Filament\Forms\Components\Repeater;use Filament\Forms\Components\TextInput;use Filament\Schema\Schema;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TextInput;
use Filament\Schema\Schema;
public function form(Schema $form): Schema
{
@@ -128,7 +128,10 @@ Next, we'll need to create our component. Create a new file at `src/Heading.php`
```php
namespace Awcodes\Headings;
use Closure;use Filament\Schema\Components\Component;use Filament\Support\Colors\Color;use Filament\Support\Concerns\HasColor;
use Closure;
use Filament\Schema\Components\Component;
use Filament\Support\Colors\Color;
use Filament\Support\Concerns\HasColor;
class Heading extends Component
{
+4 -1
View File
@@ -122,7 +122,10 @@ It's possible to define as many filters as you need, and use any component from
Filament's tables can use [Actions](../actions/overview). They are buttons that can be added to the [end of any table row](actions#row-actions), or even in the [header](actions#header-actions) of a table. For instance, you may want an action to "create" a new record in the header, and then "edit" and "delete" actions on each row. [Bulk actions](actions#bulk-actions) can be used to execute code when records in the table are selected.
```php
use App\Models\Post;use Filament\Actions\Action;use Filament\Actions\BulkActionGroup;use Filament\Actions\DeleteBulkAction;
use App\Models\Post;
use Filament\Actions\Action;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
public function table(Table $table): Table
{
@@ -310,7 +310,8 @@ TextColumn::make('title')
You may open [action modals](../actions#modals) by passing in an `Action` object to the `action()` method:
```php
use Filament\Actions\Action;use Filament\Tables\Columns\TextColumn;
use Filament\Actions\Action;
use Filament\Tables\Columns\TextColumn;
TextColumn::make('title')
->action(
@@ -412,7 +413,8 @@ TextColumn::make('id')
To customize the toggle dropdown trigger button, you may use the `toggleColumnsTriggerAction()` method, passing a closure that returns an action. All methods that are available to [customize action trigger buttons](../actions/trigger-button) can be used:
```php
use Filament\Actions\Action;use Filament\Tables\Table;
use Filament\Actions\Action;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -151,7 +151,8 @@ public function table(Table $table): Table
When deferring filters, you can customize the "Apply" button, using the `filtersApplyAction()` method, passing a closure that returns an action. All methods that are available to [customize action trigger buttons](../../actions/trigger-button) can be used:
```php
use Filament\Actions\Action;use Filament\Tables\Table;
use Filament\Actions\Action;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -209,7 +210,8 @@ TernaryFilter::make('trashed')
To customize the filters trigger buttons, you may use the `filtersTriggerAction()` method, passing a closure that returns an action. All methods that are available to [customize action trigger buttons](../../actions/trigger-button) can be used:
```php
use Filament\Actions\Action;use Filament\Tables\Table;
use Filament\Actions\Action;
use Filament\Tables\Table;
public function table(Table $table): Table
{
+3 -1
View File
@@ -150,7 +150,9 @@ public function table(Table $table): Table
You may customize the [form schema](../../forms/layout) of the entire filter form at once, in order to rearrange filters into your desired layout, and use any of the [layout components](../../forms/layout) available to forms. To do this, use the `filterFormSchema()` method, passing a closure function that receives the array of defined `$filters` that you can insert:
```php
use Filament\Schema\Components\Section;use Filament\Tables\Filters\Filter;use Filament\Tables\Table;
use Filament\Schema\Components\Section;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
public function table(Table $table): Table
{
+22 -8
View File
@@ -38,7 +38,8 @@ Actions may be created using the static `make()` method, passing its unique name
You can then pass a function to `action()` which executes the task, or a function to `url()` which creates a link:
```php
use App\Models\Post;use Filament\Actions\Action;
use App\Models\Post;
use Filament\Actions\Action;
Action::make('edit')
->url(fn (Post $record): string => route('posts.edit', $record))
@@ -98,7 +99,10 @@ You may want an action to be able to access all the selected rows in the table.
For example, you may want to have a row action that copies the row data to all the selected records. To force the table to be selectable, even if there aren't bulk actions defined, you need to use the `selectable()` method. To allow the action to access the selected records, you need to use the `accessSelectedRecords()` method. Then, you can use the `$selectedRecords` parameter in your action to access the selected records:
```php
use Filament\Actions\Action;use Filament\Tables\Table;use Illuminate\Database\Eloquent\Collection;use Illuminate\Database\Eloquent\Model;
use Filament\Actions\Action;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
public function table(Table $table): Table
{
@@ -137,7 +141,8 @@ public function table(Table $table): Table
Bulk actions may be created using the static `make()` method, passing its unique name. You should then pass a callback to `action()` which executes the task:
```php
use Filament\Actions\BulkAction;use Illuminate\Database\Eloquent\Collection;
use Filament\Actions\BulkAction;
use Illuminate\Database\Eloquent\Collection;
BulkAction::make('delete')
->requiresConfirmation()
@@ -153,7 +158,9 @@ The function allows you to access the current table `$records` that are selected
You may use a `BulkActionGroup` object to [group multiple bulk actions together](../actions/grouping-actions) in a dropdown. Any bulk actions that remain outside the `BulkActionGroup` will be rendered next to the dropdown's trigger button:
```php
use Filament\Actions\BulkAction;use Filament\Actions\BulkActionGroup;use Filament\Tables\Table;
use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -175,7 +182,8 @@ public function table(Table $table): Table
Alternatively, if all of your bulk actions are grouped, you can use the shorthand `groupedBulkActions()` method:
```php
use Filament\Actions\BulkAction;use Filament\Tables\Table;
use Filament\Actions\BulkAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -196,7 +204,8 @@ public function table(Table $table): Table
You may deselect the records after a bulk action has been executed using the `deselectRecordsAfterCompletion()` method:
```php
use Filament\Actions\BulkAction;use Illuminate\Database\Eloquent\Collection;
use Filament\Actions\BulkAction;
use Illuminate\Database\Eloquent\Collection;
BulkAction::make('delete')
->action(fn (Collection $records) => $records->each->delete())
@@ -283,7 +292,11 @@ Filament includes several prebuilt actions and bulk actions that you can add to
You may use an `ActionGroup` object to group multiple table actions together in a dropdown:
```php
use Filament\Actions\ActionGroup;use Filament\Actions\DeleteAction;use Filament\Actions\EditAction;use Filament\Actions\ViewAction;use Filament\Tables\Table;
use Filament\Actions\ActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Actions\ViewAction;
use Filament\Tables\Table;
public function table(Table $table): Table
{
@@ -378,7 +391,8 @@ ActionGroup::make([
Buttons come in 3 sizes - `sm`, `md` or `lg`. You may set the size of the action group button using the `size()` method:
```php
use Filament\Actions\ActionGroup;use Filament\Support\Enums\ActionSize;
use Filament\Actions\ActionGroup;
use Filament\Support\Enums\ActionSize;
ActionGroup::make([
// ...
+2 -1
View File
@@ -289,7 +289,8 @@ public function table(Table $table): Table
To customize the groups dropdown trigger button, you may use the `groupRecordsTriggerAction()` method, passing a closure that returns an action. All methods that are available to [customize action trigger buttons](../actions/trigger-button) can be used:
```php
use Filament\Actions\Action;use Filament\Tables\Table;
use Filament\Actions\Action;
use Filament\Tables\Table;
public function table(Table $table): Table
{
+2 -1
View File
@@ -62,7 +62,8 @@ public function table(Table $table): Table
You can add [Actions](actions) to the empty state to prompt users to take action. Pass these to the `emptyStateActions()` method:
```php
use Filament\Actions\Action;use Filament\Tables\Table;
use Filament\Actions\Action;
use Filament\Tables\Table;
public function table(Table $table): Table
{
+2 -1
View File
@@ -205,7 +205,8 @@ public function table(Table $table): Table
To customize the reordering trigger button, you may use the `reorderRecordsTriggerAction()` method, passing a closure that returns an action. All methods that are available to [customize action trigger buttons](../actions/trigger-button) can be used:
```php
use Filament\Actions\Action;use Filament\Tables\Table;
use Filament\Actions\Action;
use Filament\Tables\Table;
public function table(Table $table): Table
{