Skip to content

Provides a Draftable trait that allows FilamentPHP resource pages to have their form data saved in the browser's localStorage for later filling

License

Notifications You must be signed in to change notification settings

benjaminhansen/filament-draftable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Filament Draftable

Provides a Draftable trait that you can add to your Resource pages to allow saving data as a draft. All data is stored in your browser's localStorage and is encrypted using Laravel's encryption.

Installation

Install the package via composer:

composer require benjaminhansen/filament-draftable

Usage

<?php

namespace App\Filament\Resources\PostResource\Pages;

use BenjaminHansen\FilamentDraftable\Traits\Draftable;
use Filament\Resources\Pages\CreateRecord;

class CreatePost extends CreateRecord
{
    use Draftable;

    // add exclusions to this array to prevent them from being saved in the draft
    public ?array $excludeFromDraft = ['password'];

    // add/modify this method
    protected function getFormActions(): array
    {
        return [
            // load the existing/default form actions
            ...parent::getFormActions(),

            // append the draftable actions
            // we can use all of Filament's Action methods to customize the draftable actions
            $this->saveDraftAction(),
                // ->icon('')
                // ->label('')

            $this->loadDraftAction(),
                // ->icon('')
                // ->label('')

            $this->deleteDraftAction(),
                // ->icon('')
                // ->label('')
                // ->requiresConfirmation()
        ]
    }
}

About

Provides a Draftable trait that allows FilamentPHP resource pages to have their form data saved in the browser's localStorage for later filling

Topics

Resources

License

Stars

Watchers

Forks

Languages