vendredi 4 février 2022

Livewire & Checkbox bug

first of all, I searched the other topics to this issue and none of them helped me.

The thing is that I have checkbox condition for "checked".

@foreach ($roles as $role)
<div class="form-check form-switch">
    <input wire:click="updateRoles()" wire:model="updatedRoles" type="checkbox" id="" value=""
        @isset($user)
            @if (in_array($role->id, $user->roles->pluck('id')->toArray()))
                checked
            @endif
        @endisset
     />
    <label class="form-check-label" for=""></label>
</div>
@endforeach

everything works correctly, "checked" is displayed only when it should, but the browser wont render the checkbox checked, its not an css issue, i disabled css and its not browser issue either, i tried 5 of them.

The only thing that "fixes" this issue is if i remove "wire:model="updatedRoles" from the input, but I need this to stay there obviously so i dont really know what to do.

public $updatedRoles = [];

Thanks for any tips




Aucun commentaire:

Enregistrer un commentaire