defstudio / filament-dynamic-actions
Dynamically disable or hide actions when form is dirty
Fund package maintenance!
fabio-ivona
defstudio
paypal.me/defstudiosrl
Requires
- php: ^8.1
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2025-01-27 21:26:34 UTC
README
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
Installation
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"
Usage
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' ] )
Changelog
Please see CHANGELOG for more information on what has changed recently. Follow Us on Twitter for more updates about this package.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.