Use of Multiselect in Laravel

Use of Multiselect in HTML/ Laravel

1. Use Select2 css files.

<pre>Hello there</pre>

Here, I'm using the cdn link for select 2. If your work is offline, save the css.

2. Use Select2 js files.


Here, I'm again using the cdn for select2 js.

3. Identify the field where multiselect is needed. In my case, I am using multiselect to use multiple size of clothes, i.e. Small, Medium, Large.

For this, we have the html as:


                               Free Size                                Small                                Medium                                Large                                Extra Large                            

The main thing to consider is to use array in name and id. Here, I have used name=”select[]” and id=”select[]”. This is because of the multiple data to be inserted in the same name.

4. Default select value.

Take a look at above class name I have used, i.e. select-multple. You can use any name. Then use this name to call the following js.


5. Just make sure you are using the jQuery plugin.

6. You are all set to use the multi select option and send the data.

7. For the controller part to receive the data,

$multipleVal = $request->get('select');

$item->size = serialize($multipleVal);

Here, select is the name of the html name. I am using serialize() method to store the values in the database of $item->size. To retrieve database data, just use the unserialize() method.



April 16, 2020 2:29 AM



May 19, 2020 2:40 PM

Mrs Robinson online dating <a href=" ">NSA dating definition</a> svensk dejting online <a href=" ">Tryck matare krok</a> www. Christian dating basta dejtingsajter for franskilda pappor

Leave a reply

your email address will not be published. required fields are marked *

Name *