How to make custom forms more efficient

Hello - I have multiple forms on a Filament page. The forms all work, but the performance is very slow. Each update call takes between 2-3 seconds in my local environment. I'm worried that in production each request will take 5-10 seconds. Between all the forms on the page, there are roughly 500 form components. I tried breaking the forms up into even more forms (with each form containing less data), but the performance stayed the same. Does anyone have any advice for how to improve this performance? Each field is reactive and updates the relevant record when modified using afterStateUpdated. I would like to avoid using a traditional Update button like with standard EditRecord pages. There are a lot of data fields and if the user forgot to hit Update it would take them a long time to recreate their work. Thank you!
6 Replies
LeandroFerreira
LeandroFerreira4mo ago
Each field is reactive and updates the relevant record when modified using afterStateUpdated I think this is why your form is slow... Maybe you could use something like unsavedChangesAlerts to alert users if they forgot to hit the button https://filamentphp.com/docs/3.x/panels/configuration#unsaved-changes-alerts
bwurtz999
bwurtz999OP4mo ago
Wow this is an awesome feature. Didn't realize this existed. Thank you! Does this work on forms on custom pages? The docs say this only applies to create and edit pages, as well as open modals
LeandroFerreira
LeandroFerreira4mo ago
yep. If you want to add it in custom pages, you should inspect the code and develop it
bwurtz999
bwurtz999OP4mo ago
Thank you! Just a clarifying question - is the reason the updates are so slow because Filament is re-rendering each form on the page every time an update is made? Is there a way to essentially use wire:ignore for forms that are not modified?
LeandroFerreira
LeandroFerreira4mo ago
yes, this will render every livewire request I don't think wire:ignore will make sense if you want to make the fields live
bwurtz999
bwurtz999OP4mo ago
Got it. Thanks
Want results from more Discord servers?
Add your server