Skip to content

defstudio/filament-dynamic-actions

Repository files navigation

Filament Dynamic Actions

Latest Version on Packagist Code Style Total Downloads License Twitter Follow

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.