aliqasemzadeh / livewire-bootstrap-modal

Dynamic Laravel Livewire Bootstrap modals.
35 stars 12 forks source link

Only arrays and Traversables can be unpacked #12

Closed danyderigon closed 5 months ago

danyderigon commented 7 months ago

I recently upgraded a Livewire 2 project to Livewire 3. I also switched from the bastinald/laravel-livewire-modals package to yours.

Since then I've had this error: Only arrays and Traversables can be unpacked

I did, however, make a very simple modal

app/Http/Livewire/TestModal.php

<?php

namespace App\Http\Livewire;

use Livewire\Component;

class TestModal extends Component
{
    public function render()
    {
        return view('livewire.test-modal');
    }
}

resources/views/livewire/test-modal.blade.php

<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title">Modal title</h5>
            <button
                type="button"
                class="btn-close"
                data-bs-dismiss="modal"
                aria-label="Close"
            ></button>
        </div>
        <div class="modal-body">
            <p>Modal body text goes here.</p>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
                Close
            </button>
            <button type="button" class="btn btn-primary">Save changes</button>
        </div>
    </div>
</div>

And I call it like that in another Livewire component :

<button type="button" wire:click="$dispatch('showModal', 'test-modal')">
    {{ __('Display test modal') }}
</button>

Do you have any idea what the problem is?

The complete error :

https://flareapp.io/share/x7Xw4nwP/claim/FNle9JTUDEyBnKGaBz8BILLUrfJlMNK0

aliqasemzadeh commented 7 months ago

Hi Please give me more detail about your project.

danyderigon commented 7 months ago

Sorry I closed this issue because my stack was completely broken ...

Nevertheless, I have a question:

The following code (provided in the readme doesn't work )

 <button type="button" wire:click="$dispatch('showModal', ['alias' => 'pro.modals.restaurant.food-types-modal'])">
    {{ __('Not working button') }}
</button>

Capture d’écran 2023-12-04 à 09 03 38

But this code works

 <button type="button" wire:click="$dispatch('showModal', { data: {alias:'pro.modals.restaurant.food-types-modal', params: {} } })">
    {{ __('Working button') }}
</button>

Have I missed something ?

aliqasemzadeh commented 7 months ago

I have this problem on aliqasemzadeh/bap and I am working on it. Just wait.

aliqasemzadeh commented 5 months ago

@danyderigon Check update now.