I've been beating my head against a wall about this behavior all day long. I can inject an Image ID directly into the array created on load. That check box will select automatically as expected. But if I uncheck that box, it suddenly breaks the whole script and I start getting 404's when I click on that checkBulk() button. It's like changing the state of the checkbox is somehow tripping up livewire, but nothing is being logged.
May 26, 2024
3
Level 1
Strange behavior in Livewire
I've got a script that creates a list of images, and each image created has a checkbox below it for bulk editing image captions.
Below is my Blade template
<div class="col-12 col-lg-3">
<div class="text-center">
<a href="https://cdn.inspectorstudio.com/{{ $image->image_url }}" target="_blank" data-lightbox="image-{{ $loop->iteration}}" data-title="{{ $image->image_caption }}"><img class="img-thumbnail" src="https://cdn.inspectorstudio.com/{{$image->thumb_url}}"></a>
</div>
<div class="w-100 text-center pt-2">
<input class="form-check-input" type="checkbox" wire:model="section_two_bulk" id="image_{{ $image->id }}" value="{{ $image->id }}">
<label class="form-check-label" for="image_{{ $image->id }}">
Bulk Select
</label>
</div>
</div>
I've also got
public $section_two_bulk = [];
I created a button that calls a function that does the below --
public function checkBulk(){
dd( $this->section_two_bulk );
}
If I leave the checkboxes blank, it'll DD an empty array as you would expect. However, if I check any number of the checkboxes displayed, that function throws a 404 error.
I have no idea what's going on or why I can't get the values of these checkboxes successfully.
Please or to participate in this conversation.