Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Exception "Only arrays and Traversables can be unpacked" when catching event filepond-upload-started in PHP. #27

Open
booni3 opened this issue Oct 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@booni3
Copy link

booni3 commented Oct 14, 2024

What happened?

#[On('filepond-upload-started')]
public function uploadStarted(): void
{
    dd('fail'); // Only arrays and Traversables can be unpacked
}

#[On('filepond-upload-finished')]
public function uploadFinished($files): void
{
    dd($files, 'ok'); // OK
}

Catching the events in Alpine works, although $event.detail only shows the model name files

<div x-data
     x-on:filepond-upload-started="console.log('started', $event.detail)"
     x-on:filepond-upload-finished="console.log('finished', $event.detail)"
>
    <x-filepond::upload wire:model="files" multiple image-preview-height="150"/>
</div>

How to reproduce the bug

Package Version

1.2.3

PHP Version

8.3

Laravel Version

11

Which operating systems does with happen with?

No response

Notes

No response

@booni3 booni3 added the bug Something isn't working label Oct 14, 2024
@spacedogstudios
Copy link

This error can be fixed by naming the object property in the payload. For example, the dispatch in upload.blade.php could become:

$dispatch('filepond-upload-started', { 'attribute': '{{ $wireModelAttribute }}' });

The same with the filepond-upload-reset event:

$dispatch('filepond-upload-reset', { 'attribute': '{{ $wireModelAttribute }}' });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants