Show selected Laravel checkbox after page submission

  laravel, php

I have name and checkbox on my website and both are mandatory. There are 7 checkbox and at least 1 is important. I submit the form with name as empty and at least 1 checkbox selected with POST request. The result shows back and says Please enter the name and Please select the checkbox and selected checkbox is mandatory(which is not shown) . The project is in Laravel.

@foreach($data as $boat)
    <div class="form-check">
        <input class="form-check-input" type="checkbox" value="{{ ($boat->name) }}"
            id="{{$boat->name}}" checked="checked"
            name="boats[]" >
        <label class="form-check-label" for="{{$boat->name}}">
            {{$boat->name}}
        </label>
    </div>
 @endforeach
            

Source: Ask PHP

LEAVE A COMMENT