1

I have a input with a collection that should display as a drop down but instead it's displaying as a select box. How do i make it a drop down?

<%= f.input :fund, collection: funds, prompt: 'Select Fund', label: false, input_html: { multiple: true } %>
Robbo
  • 1,292
  • 2
  • 18
  • 41

2 Answers2

2

Add as: :select to your HTML and remove the multiple: true attribute. The select tag as a dropdown list does not support multiple selections without a JavaScript library like Select2.

<%= f.input :fund, as: :select, collection: funds, prompt: 'Select Fund', label: false %>

Here is an example of each type of select: http://jsfiddle.net/scarver2/s1nckfq5/

CITE: https://github.com/plataformatec/simple_form#usage

scarver2
  • 7,887
  • 2
  • 53
  • 61
0

I answered a similar question here but you don't say what context (web framework) you're using.

You can use SimpleForm, Bootstrap and Bootstrap-Select. There is a Rails Gem for it. See my other answer for details.

Community
  • 1
  • 1
starfry
  • 9,273
  • 7
  • 66
  • 96