dousha4804 2018-08-20 07:51
浏览 17

选择的插件不会在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] (

  • 写回答

1条回答 默认 最新

  • dsaj20411 2018-08-20 12:46
    关注

    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

    评论

报告相同问题?