Reputation: 3638
I'm using Slim Select for my select fields in my Rails 6 app. In order to allow users to select multiple options in the select, I have to add the attribute multiple
to my select tag.
So it renders HTML, like: <select id="foo" multiple>
.
How do I get multiple
to show in the select tag?
I've read:
And I've tried:
<%= f.collection_select :foo, Tag.order(:name),:id,:name, include_blank: true, :html => 'multiple' %>
<%= f.collection_select :foo, Tag.order(:name),:id,:name, include_blank: true, input_html: { data: { multiple: "required"} } %>
<%= f.collection_select :foo, Tag.order(:name),:id,:name, include_blank: true, :html => {:multiple => true} %>
<%= f.collection_select :foo, Tag.order(:name),:id,:name, include_blank: true, multiple: true %>
<%= f.collection_select :foo, Tag.order(:name),:id,:name, include_blank: true, :multiple => true %>
However, none of these add multiple
in the select tag.
Upvotes: 1
Views: 442
Reputation: 6253
make sure :foo is an array that can save multiple ids, and put multiple: true as follow
<%= f.collection_select :foo, Tag.order(:name),:id,:name, {} , {multiple: true, class: '...'} %>
Upvotes: 0