문제

I can't figure out how to enable multiple selection for a input in Ransack.

<%= search_form_for @q,url: search_table_path do |f| %> 
   <%= f.label :country_code_eq %>

   <%= f.select :country_code_eq, 
    options_from_collection_for_select(Country.all, :code, :name),
    {prompt: 'Select a Country',multiple: true,include_blank: false}%> 

   <%= f.label :date_start %>
   <%= f.text_field :date_start %>
   <%= f.submit %> 
<% end %>

The multiple: true does not work as I expected. It only show a normal dropdown box not a multiple selection box.

My first question is how to enable multiple selection ?

And my Second question is how do I keep the selected value and show it after the page loaded in selection box ?

도움이 되었습니까?

해결책

I found the answer

<%= f.select :country_code_in, Country.all.map {|country| [country.name,country.code] }, {include_blank: 'All'}, {multiple: true}  %> 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top