Want to enable/disable a Filament action when the form is dirty/unsaved? With this package, it will be as easy as:
\Filament\Actions\Action::make('download')
->icon('heroicon-o-document-arrow-down')
->action(function($record){...})
->disabledWhenDirty()
all with Alpine, no need of extra livewire requests to the backend
You can install the package via composer:
composer require defstudio/filament-dynamic-actions
You can publish the translations files with:
php artisan vendor:publish --tag="filament-dynamic-actions-translations"
This package simply adds a new method to the page actions that allows to disable it when the form is dirty (all parameters are optional, default values will be used if missing):
\Filament\Actions\Action::make('download')
->icon('heroicon-o-document-arrow-down')
->action(function($record){...})
->disabledWhenDirty(
message: "oops! There are unsaved changes",
disabledClass: 'disabled:opacity-100 disabled:bg-red-500',
ignoredFields: [
'path.also_with_subpath.of.a.field.i_dont_care_to_check'
]
)
Please see CHANGELOG for more information on what has changed recently. Follow Us on Twitter for more updates about this package.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.