ClearField Action
An action that allows users to quickly reset all form fields with customizable confirmation dialogs and notifications.
Author:
Anish Regmi
Documentation
- Features
- Requirements
- Installation
- Usage
- Configuration
- Available Methods
- Compatibility
- License
- Author
A Filament action that allows users to quickly reset all form fields with customizable confirmation dialogs and notifications.
#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 & v5
#Requirements
- PHP 8.1+
- Filament 4.0+ | 5.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 actioncolor- Default color schemelabel- Default label texttooltip- Default tooltip textrequires_confirmation- Whether to show confirmation by defaultconfirmation_title- Default confirmation dialog titleconfirmation_description- Default confirmation dialog descriptionshow_notification- Whether to show notification by defaultnotification_title- Default notification titlenotification_body- Default notification body
#Available Methods
requiresConfirmation(bool|Closure $condition)- Enable/disable confirmation dialogconfirmationTitle(string|Closure|null $title)- Set confirmation dialog titleconfirmationDescription(string|Closure|null $description)- Set confirmation dialog descriptionbeforeReset(Closure $callback)- Callback executed before clearing fieldsafterReset(Closure $callback)- Callback executed after clearing fieldsshowNotification(bool|Closure $show)- Show/hide success notificationnotificationTitle(string|Closure|null $title)- Set notification titlenotificationBody(string|Closure|null $body)- Set notification bodyicon(string $icon)- Set action iconcolor(string $color)- Set action colorlabel(string|null $label)- Set action labeltooltip(string $tooltip)- Set action tooltip
#Compatibility
This package supports:
- Filament v4.0+
- Filament v5.0+
#License
MIT
#Author
anishregmi17
The author
I am Anish Regmi, a full-stack web developer from Nepal. I have a strong foundation in PHP, Laravel, Filament, and JavaScript, and I specialize in building modern, scalable web applications. I enjoy creating clean, maintainable code and delivering seamless user experiences across both frontend and backend development.
From the same author
Maskable Entry
A reusable maskable entry component for Filament Infolists to hide and toggle sensitive values.
Author:
Anish Regmi
TextInput Entry
An editable text input entry that allows users to edit text fields directly in the infolist view without navigating to an edit page.
Author:
Anish Regmi
Featured Plugins
A selection of plugins curated by the Filament team
Custom Dashboards
Let your users build and share their own dashboards with a drag-and-drop interface. Define your data sources in PHP and let them do the rest.
Filament
Custom Fields
Eliminate custom field migrations forever. Let your users create and manage form fields directly in Filament admin panels with 20+ built-in field types, validation, and zero database changes.
Relaticle
Data Lens
Advanced Data Visualization for Laravel Filament - a premium reporting solution enabling custom column creation, sophisticated filtering, and enterprise-grade data insights within admin panels.
Padmission