If your form is made with Laravel collective form and you are searching for how to select multiple options in laravel collective form then this tutorial is for you. In this example, I will show you laravel collective form select multiple example. I will create a simple collective form and then I will add a select box with the user list with multiple select options 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 select multiple from select box in laravel collective form:

laravel-collective-multiple-select-option-tutorial

Laravel collective select option accepts an array. So we have to pass an array like that:

$users = User::select('id','name')->get()->pluck('name','id');

 

Now pass this in collective form like:

{!! Form::open(['route' => 'user.store', "method" => "post", "class" => "form", "id" => "createUserForm"]) !!}
    {!! Form::token() !!}
    <div class="form-group mt-3 mb-2">
        {!! Form::label("user", "Select User") !!}
        {!! Form::select('user[]',$users, null, ['multiple' => true, 'placeholder' => 'Pick a size...']) !!}
        {!! $errors->first("user",'<span class="help-block">:message</span>') !!}
    </div>
    {!! Form::submit("Submit", ["class"=>"btn btn-primary"]) !!}
{!! Form::close() !!}

 

Read also: How To Use Select Option In Laravel Collective Form

 

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

{
    "_token": "xDbOBo3TxWuc5xEbvExTv3E8lSLjiGsEdLeoqMjr",
    "user": [
        "2",
        "3",
        "4"
    ]
}

 

Conclusion

Hope this how to select multiple option in laravel collective form tutorial will help. After completing this laravel collective formselect multiple tutorial, your concept will be clear about how to use the collective select multiple option form in laravel. Hope this select multiple laravel collective form tutorial will clear your concept about laravel collective formselect multiple.