user6770399
user6770399

Reputation:

Chosen plugin don't sending selected data on php

I have simple select, He was work before install chosen plugin

<select id="product_brands" class="chosen-select form-control" multiple data-placeholder="Select brands">
@foreach($brands as $brand)
    <option name="product[brands][]" value="{{$brand->brand_id}}"> {{$brand->brand_name}} </option>
@endforeach 

Set chosen

$(".chosen-select").chosen({width: "100%"});

And when I do print_r in my php script I get nothing from selected data

array:2 ["main" => array:2 ["name" => "test", "count" => "0" ] "contacts" => "1196656" ]

There should have been a list product[brands] (

Upvotes: 2

Views: 135

Answers (1)

user6770399
user6770399

Reputation:

I figured out what the problem is. I did not correctly indicate the type of array in the form. Need make then: 1. Add in select tag attribute - multiple="multiple"
2. Add in select tag attribute - name="product[brands][]"

<select id="product_brands" class="chosen-select form-control" multiple="multiple" name="product[brands][]" data-placeholder="Select brands">

And everything will work as it should

Upvotes: 1

Related Questions