SpatieMediaLibraryFileUpload auto saving

Suggestions for automatically saving the uploaded or reordered images automatically without. I know i can probably do afterStateUpdated(), but then I have to figure out all the logic to do the save. I know I cant just do $this->form->getState() like i would if it was a submit method. Must be something similar though. Thoughts?
13 Replies
Mark Chaney
Mark ChaneyOP2y ago
im using it with s3 if it makes a difference basically can i tap into the same "magic" that $this->form->getState() does but with afterStateUpdated() or whatever other method you suggest
Dennis Koch
Dennis Koch2y ago
Can you get it via fn ($livewire) => $livewire->getFormState() or similar?
Mark Chaney
Mark ChaneyOP2y ago
@Dennis Koch great idea, a little tweak, but ->afterStateUpdated(fn($livewire) => $livewire->form->getState()) does the job
awcodes
awcodes2y ago
Maybe even mutateFormDataBeforeSave($data) There’s another one for create too.
Dennis Koch
Dennis Koch2y ago
I think he wants instant save.
awcodes
awcodes2y ago
Could be.
Mark Chaney
Mark ChaneyOP2y ago
yep, i want instant save. Its not saving order for some reason though. need to see if thats triggering properly after a image reorder yep, changing order does not trigger afterStateUpdated()
awcodes
awcodes2y ago
i don't know that it can since the ordering is on the front end via JS
Mark Chaney
Mark ChaneyOP2y ago
@awcodes dont say that and ruin my day 😛
awcodes
awcodes2y ago
looking at the code it looks like it should be though
Mark Chaney
Mark ChaneyOP2y ago
well its not saving and i threw a ray() into that afterStateUpdate() and it never ran when i reordered.
awcodes
awcodes2y ago
is there a network request sent when you reorder them? for some reason sometimes ray() doesn't log inside callbacks. Haven't figured that one out yet.
Mark Chaney
Mark ChaneyOP2y ago
hmm, it does do a network request with a livewire message i verified though that using a submit button and
public function submit(): void
{
$this->form->getState();
}
public function submit(): void
{
$this->form->getState();
}
, the order is properly being saved.
Want results from more Discord servers?
Add your server