Multiple selection dropdown in php

Hello In this blog on Multiple Selection Dropdown In Php. If you have any questions, feel free to ask. This article was updated after adding validation and wrapping up the endpoints.
Our specific codebase is Laravel 4, but the process described here will work in all other Laravel versions.
Our endpoints.php looks like this.
All Laravel functions require the use of a Route. We will explain those in a bit.
You can find the source code for Laravel 5, Laravel 4, and up here.
If you need help, check the previous post or the user questions page on Stack Overflow.
Using Multiple Select With Search Box
Now we can get to the hard part.

Preview:

index.html

<html>

<head>

    <title>Multiple Selection Dropdown In Php Example - LARATuto.com</title>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/css/bootstrap-select.css" />

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/js/bootstrap-select.min.js"></script>

    <style type="text/css">

        .dropdown-toggle{

            height: 40px;

            width: 400px !important;

        }

    </style>

</head>

<body>

    <div class="container">

        <div class="row">

            <div class="col-md-8 offset-2 mt-5">

                <div class="card">

                    <div class="card-header bg-info">

                        <h6 class="text-white">Multiple Selection Dropdown In Php Example - LARATuto.com</h6>

                    </div>

                    <div class="card-body">

                        <form method="post" action="{{ route('Getdata') }}" enctype="multipart/form-data">

                            @csrf

                            <div class="form-group">

                                <label>Name</label>

                                <input type="text" name="name" class="form-control"/>

                            </div>  

                            <div class="form-group">

                                <label><strong>Description :</strong></label>

                                <textarea class="ckeditor form-control" name="description"></textarea>

                            </div>

                            <div class="">

                                <label><strong>Select Category :</strong></label><br/>

                                <select class="selectpicker" multiple name="category[]">

                                  <option value="php">PHP</option>

                                  <option value="react">React</option>

                                  <option value="jquery">JQuery</option>

                                  <option value="javascript">Javascript</option>



                                </select>

                            </div>

                            

                            <div class="text-center" style="margin-top: 10px;">

                                <button type="submit" class="btn btn-success">Save</button>

                            </div>

                        </form>

                    </div>

                </div>

            </div>

        </div>

    </div>    

</body>
  

</html>
Output:
array:4 [▼

  "_token" => "S4doCz5Ffsdfewrwer534534rgdty75834656659866d"
  "name" => "Raj Patel"
  "description" => "Test description"
  "category" => array:3 [▼
    0 => "php"
    1 => "react"
    2 => "jquery"

  ]

]

Leave a Comment