anish/clearfield-action

A Filament action that allows users to quickly reset all form fields with customizable confirmation dialogs and notifications.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/anish/clearfield-action

v1.0.1 2026-01-03 12:40 UTC

This package is auto-updated.

Last update: 2026-01-03 12:42:50 UTC


README

A Filament action that allows users to quickly reset all form fields with customizable confirmation dialogs and notifications.

clearaction

Features

  • One-click form field clearing
  • Customizable icons and colors
  • Optional confirmation dialog
  • Success notifications
  • Works with Create and Edit pages
  • Customizable callbacks (before/after reset)
  • Compatible with Filament v4

Requirements

  • PHP 8.1+
  • Filament 4.0+
  • Laravel 10+

Installation

You can install the package via Composer:

composer require anish/clearfield-action

Usage

Basic Usage

Add ClearFieldAction to your resource page's create record or edit record header actions:

<?php

namespace App\Filament\Resources\Users\Pages;

use Filament\Resources\Pages\CreateRecord;
use App\Filament\Resources\Users\UserResource;
use Anish\ClearFieldAction\Actions\ClearFieldAction;

class CreateUser extends CreateRecord
{
    protected static string $resource = UserResource::class;

    protected function getHeaderActions(): array
    {
        return [
            ClearFieldAction::make(),
        ];
    }
}

With Confirmation

ClearFieldAction::make()
    ->requiresConfirmation()
    ->confirmationTitle('Clear Form Fields?')
    ->confirmationDescription('Are you sure you want to clear all form fields?')

Custom Notification

ClearFieldAction::make()
    ->notificationTitle('Fields Cleared')
    ->notificationBody('All form fields have been reset successfully.')

With Callbacks

ClearFieldAction::make()
    ->beforeReset(function ($livewire) {
        // Execute before clearing fields
        Log::info('Clearing form fields');
    })
    ->afterReset(function ($livewire) {
        // Execute after clearing fields
        Log::info('Form fields cleared');
    })

Hide Notification

ClearFieldAction::make()
    ->showNotification(false)

Custom Icon and Color

ClearFieldAction::make()
    ->icon('heroicon-o-x-mark')
    ->color('danger')
    ->label('Clear All')

Configuration

Publish the config file to customize default settings:

php artisan vendor:publish --tag=clearfield-action-config

Available configuration options:

  • icon - Default icon for the action
  • color - Default color scheme
  • label - Default label text
  • tooltip - Default tooltip text
  • requires_confirmation - Whether to show confirmation by default
  • confirmation_title - Default confirmation dialog title
  • confirmation_description - Default confirmation dialog description
  • show_notification - Whether to show notification by default
  • notification_title - Default notification title
  • notification_body - Default notification body

Available Methods

  • requiresConfirmation(bool|Closure $condition) - Enable/disable confirmation dialog
  • confirmationTitle(string|Closure|null $title) - Set confirmation dialog title
  • confirmationDescription(string|Closure|null $description) - Set confirmation dialog description
  • beforeReset(Closure $callback) - Callback executed before clearing fields
  • afterReset(Closure $callback) - Callback executed after clearing fields
  • showNotification(bool|Closure $show) - Show/hide success notification
  • notificationTitle(string|Closure|null $title) - Set notification title
  • notificationBody(string|Closure|null $body) - Set notification body
  • icon(string $icon) - Set action icon
  • color(string $color) - Set action color
  • label(string|null $label) - Set action label
  • tooltip(string $tooltip) - Set action tooltip

Compatibility

This package supports:

  • Filament v4.0+

License

MIT

Author

anishregmi17