What seems to be the problem:
public $selectedValues = [];
public function mount() {
$this->selectedValues = $databaseModel->pluck('id')->map(function($id) {
return (string) $id;
})->all();
}
When not making it a string the checkboxes are keep coming back with the ‘checked’ values. Also when not checked in the UI.
Steps to Reproduce:
// $types is an Eloquent collection here
@foreach ($types as $type)
<input type="checkbox" wire:model="selectedValues" value="{{ $type->id }}" /> {{ $type->description }}
@endforeach
When clicking the checkboxes (not the ones in the $selectedValues
) everything goes well, when clicking the $selectedValues, they are coming back to the default you set in the component class itself.
Are you using the latest version of Livewire:
No, 2.2.8 I am using.
Do you have any screenshots or code examples: