I'm trying to use Bootstrap Multiselect in my rails app in combination with a search bar.
Demo bootstrap code for Multiselect (what I'm trying to recreate):
<select class="select" multiple data-mdb-placeholder="Example placeholder" multiple>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
<option value="5">Five</option>
</select>
My view file includes the code below, which renders a box that shows the options but the only way to select multiple ones is by doing ctrl+shift - which is definitely something I don't want.
<div class="row">
<div class="col-md-12">
<%= form_with(model: @post, url: posts_path, method: :get) do |form| %>
<%= search_field_tag :search, params[:search], placeholder: "Look for Post", class: "form-control" %>
<%= select_tag 'Post Categories', options_for_select(@categories.map{|c| c}), :multiple => true, class: "form-control" %>
<%= form.submit "Search"%>
<% end %>
</div>
</div>
Some of the things I have tried so far: The class of the select_tag line is "form-control" now, but I tried using
class="select"
class="select" multiple data-mdb-filter="true">
I want to use the bootstrap multiselect but also the form_with so that I can pass parameters from the dropdown menu and the search bar to my controller. It would be awesome to have everything in the same line, but I couldn't find out how to do that either.
Any thoughts would be appreciated!
ruby 2.7.2p137 bootstrap 4