How to Warn Users of Unsaved Changes on the TenantProfile Page?
Hi Guys, I have a page "EditCompanyProfile" which extends
EditTenantProfile. Editing and saving work fine, but I need to warn the user if they don't save their changes before leaving, as there are a dozen fields there. At the moment, the user can leave without warning. As far as I understood from a discussion about warnings on pages, this issue was resolved with this solution https://github.com/filamentphp/filament/issues/9992, but somehow, it doesn't work for me. Any help is appreciated. Thanks. Running on Filament v3.2.62.Solution
Okay folks, as far as I understand, the "Unsaved Changes Alert" feature has not yet been implemented in the files for editing the Tenant Profile. I don't feel confident enough as a developer to submit a pull request yet, but I'd like to share my solution approach.
I got it working in the following way:
In my
Then, I looked at the template set in EditTenantProfile, copied it, and customized it with my own:
At the end, I inserted this:
After that, it worked.
I got it working in the following way:
In my
EditCompanyProfile file (which extends EditTenantProfile), I added use HasUnsavedDataChangesAlert; (\Filament\Pages\Concerns\HasUnsavedDataChangesAlert).Then, I looked at the template set in EditTenantProfile, copied it, and customized it with my own:
protected static string $view = 'filament.pages.tenancy.edit-tenant-profile';At the end, I inserted this:
<x-filament-panels::page.unsaved-data-changes-alert /> before the </x-filament-panels::page>.After that, it worked.