i would possibly create a trait to deal with photos and call that instead of dispatching events
Remember that temporary file uploads are just that so I would not rely on them still being around outside of the current component
I'm having some trouble with files and dispatching. I'm collecting files (photos) in an array via an input and then trying to dispatch this array to the parent livewire component (a form) so they may be processed / saved via Medialibrary on form submit.
$this->dispatch('photosUploaded', $this->photos);
Is sending it off, and a dd($this->photos); confirms it's populated and happy till the very last second, but when get it on the other end:
protected $listeners = [
'photosUploaded' => 'handlePhotos',
];
public function handlePhotos($storedPhotos)
{
$this->photos = $storedPhotos;
}
and dd($storedPhotos); I just get an array with the correct number of keys but no values.
I'm using dispatch successfully for other components (that have "normal" arrays however" and I've triple checked everything. Is Livewire forgetting these objects by design?
I have tried manually creating an array of photo arrays with path and name since that's all I need, but that's creating other issues down the road. Is merging this component back into the parent livewire component the only way for it to work as intended? They're separated as both have gotten pretty big and I was trying to keep things neat.
i would possibly create a trait to deal with photos and call that instead of dispatching events
Remember that temporary file uploads are just that so I would not rely on them still being around outside of the current component
Please or to participate in this conversation.