2

I have an array I am using select2 on but I would like the same values to be picked multiple times. Is there a way to enable this functionality? My code is below:

#home.js
$(document).ready(function(){ 
    $("#productdropdown").select2({
        allowClear: true,
        placeholder: "Select a product..."
    });
});

then in my view

#index.html.erb
<%= form_tag manuals_path, method: :post, remote: true do %>
    <%= form_tag manuals_path, method: :post, remote: true do %>
    <%= select_tag :device, options_from_collection_for_select(@products, :id, :full_name), id: "productdropdown", multiple: true %>
    <%= submit_tag 'CREATE MYMANUAL', class: 'submit', id: "generate" %>
<% end %>

and in the controller

  def index
    @products = Product.usable
  end
Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
barnett
  • 1,572
  • 2
  • 13
  • 25

0 Answers0