我有一个集合的输入,应显示为下拉菜单,但它显示为一个选择框。我如何让它下降?简单的窗体输入作为下拉框不选择框
<%= f.input :fund, collection: funds, prompt: 'Select Fund', label: false, input_html: { multiple: true } %>
我有一个集合的输入,应显示为下拉菜单,但它显示为一个选择框。我如何让它下降?简单的窗体输入作为下拉框不选择框
<%= f.input :fund, collection: funds, prompt: 'Select Fund', label: false, input_html: { multiple: true } %>
添加as: :select
到你的HTML和删除multiple: true
属性。选择标记作为下拉列表不支持没有像Select2这样的JavaScript库的多个选择。
<%= f.input :fund, as: :select, collection: funds, prompt: 'Select Fund', label: false %>
下面是每个类型的选择的一个例子:http://jsfiddle.net/scarver2/s1nckfq5/
我回答过类似的问题,但here你不说什么情况下(web框架)你使用。
您可以使用SimpleForm,Bootstrap和Bootstrap-Select。它有一个Rails Gem。详情请参阅my other answer。
是的,我试过了,但不起作用 – Robbo