How to set state 'is loading' or 'blocked' in modal form
Is it possible to set the 'loading' state of a form in a modal when interacting with a custom field I've created? I've made a custom form field (Livewire component) for uploading large files and I want to disable clicking the 'save' button while it is uploading in the background. Sort of the same state you see when clicking 'save' - with the loading indicator showing on the 'save' button (see attached screenshot). Or maybe not a loading state but blocking the save button while uploading, depending on the possibilities.
7 Replies
Is this in a Panel or in a standalone Form Builder?
In panel
In the screenshot above, where is the custom Livewire component exactly? Is it wrapping just the last field? (Of upload een...)
Yes, the form 'field' component 'Of upload een...' and the field below it
So if the field is in its own Livewire component, I think you'll need to emit an event up to the modal component and the set a
disabled
attribute on the button. If it's all in the same Livewire component though, you can just set the property directly.Ok thanks. Is there any example on how to listen for the event I'll be emitting on a modal? I can't seem to find this in the docs.
Where you emit/listen will depend on the structure of your page but this should give you the general idea:
https://livewire.laravel.com/docs/events#listening-for-events
Laravel
Events | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.