2017-01-11 27 views
0

如何在collection_select中使用引導程序下拉列表。這是我的代碼Bootstrap和collection_select

<%= collection_select(:item, :PriorityId, Priority.all, :PriorityId, :Priority, {:include_blank => true}, {:class => 'dropdown-menu'}) %> 

但我希望它是一個自舉下拉列表,而不是一個普通的HTML選擇

回答

1

form-control類添加到您的代碼:

<%= collection_select(:item, :PriorityId, Priority.all, :PriorityId, :Priority, {:include_blank => true}, {:class => 'form-control'}) %> 

form-control申請在同Bootstrap 34

+0

謝謝。它看起來更好,但不是文檔中的內容,圓角邊緣,灰色選擇和下拉列表中的陰影。它使用按鈕和ul看到這裏 - http://getbootstrap.com/components/#dropdowns –

+0

如果沒有人給出更好的答案,我會接受答案。 –

+0

@HassanVoyeau你說它不*看起來像你在上面給我的鏈接中的例子?你有沒有可能與形式控制相沖突的任何樣式......就像在'scaffolds.css'中一樣 – BigRon