If your form is made with Laravel collective form and you are searching for how to work with the checkbox then this tutorial is for you. In this example, I will show you Laravel collective checkbox example. I will create a simple collective form and then I will add a checkbox field and then we will submit it then we will return the response from the controller.

You know that Laravel collective form is a little bit different and complex than the normal HTML form. So let's see the example code of the Laravel collective form checkbox:

laravel-collective-form-checkbox-example

Now see the laravel collective form checkbox form code:

{!! Form::open(['route' => 'user.store', "method" => "post", "class" => "form", "id" => "createUserForm"]) !!}
    {!! Form::token() !!}
    <div class="form-group mt-3 mb-2">
        {!! Form::label("is_active", "Isactive") !!}
        {!! Form::checkbox("is_active", true) !!}
        {!! $errors->first("name",'<span class="help-block">:message</span>') !!}
    </div>
    {!! Form::submit("Submit", ["class"=>"btn btn-primary"]) !!}
{!! Form::close() !!}

 

Read also: How To Use Collective Form In Laravel 9 Application

 

Now if you submit this form with data then you will see the following output:

{
   "_token": "xDbOBo3TxWuc5xEbvExTv3E8lSLjiGsEdLeoqMjr",
   "is_active": "1"
}

 

Conclusion

Hope this laravel collective checkbox example tutorial will help. After completing this laravel collective formcheckbox tutorial, your concept will be clear about how to use the collective checkbox form in laravel. Hope this laravel collective form checkbox tutorial will clear your concept about laravel collective checkbox form.