Unsavedchanges feature outside of panels

Can you enable "unsaved changes" feature per form? F.e - when using form on a custom page, outside of panel
Solution
Answering myself, turns out you can, there is HasUnsavedDataChangesAlert trait that you can use and component: <x-filament-panels::page.unsaved-data-changes-alert />

// in your custom page

class ViewWorkRequest extends ViewRecord
{
    use HasUnsavedDataChangesAlert;


    public function mount(int|string $record): void
    {
        parent::mount($record);
        $this->hasUnsavedDataChangesAlert();
        $this->form->fill();
    }
 }

// in blade file
<div>
    {{ $this->form }}

    <div class="mt-6 text-end">
        <x-filament::button wire:click="save">
            Save
        </x-filament::button>
    </div>

    <x-filament-panels::page.unsaved-data-changes-alert />
</div>
Was this page helpful?