Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mrosenblatt's avatar

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.

0 likes
3 replies
mrosenblatt's avatar

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.

Snapey's avatar

how are you looping over images?

how are you triggering your bulk method?

What type is section_two_bulk?

mrosenblatt's avatar

@Snapey Fair questions.

A bit of background on what this is might shed some light. This is a page used to add images to property inspection reports following Florida OIR 1802 Document (Uniform Wind Mitigation) standards. There are 7 sections to the document, hence the "section_one_bulk", "section_two_bulk", "section_three_bulk", etc.... Each section needs to be manipulated separately from one another. It was originally a single array with sub-arrays, but I made each section completely isolated while trying to troubleshoot this behavior.

Images are database driven. The files themselves are stored on S3 storage, but their pointers are all in the database. Each section works the same way --

public function fetchElevations()
    {
        $this->elevation_images = WindImages::where( 'report_id' , $this->report_id )->where('wind_section','elevations')->orderBy('created_at','ASC')->get();
        foreach( $this->elevation_images as $key ){
            $this->captions[ $key->id ] = $key->image_caption;
        }
    }

Each section has an array for bulk image selection. The point of the bulk selection is to modify their captions all at once, so you don't need to go to each image and copy/paste your caption a million times over. The checkboxes placed under each image correspond to said image within that section.

If you dd() the array (e.g. dd( $this->section_one_bulk) ) for the checkboxes prior to selecting a checkbox, you get the dump of an empty array ("[]"), which is expected. The moment you select any one of the checkboxes on the page, the same method to check that variable turns into a 404 error within Livewire. No errors are written into the Javascript console. No errors are written into the server log.

The below is a debug function I wrote --

public function checkBulk(){
        logger('Check bulk initiated');
        dd( $this->bulk_edit );
    }

If you trigger that function without a checkbox selected, it will write to the log. Once a checkbox is selected anywhere on the page, it won't write to the log anymore. It just throws a 404.

Please or to participate in this conversation.