18
我有它創建了一個選擇框如下:rails選擇表單標籤 - 如何添加默認的「全部」選項?
<%=select_tag "people", options_from_collection_for_select(@people, "id", "name")%>
這給每個人一個項目,問題是我想一個「全民」值0,選擇添加默認負載選擇?
確實在軌select_tag 3支持呢?
感謝
我有它創建了一個選擇框如下:rails選擇表單標籤 - 如何添加默認的「全部」選項?
<%=select_tag "people", options_from_collection_for_select(@people, "id", "name")%>
這給每個人一個項目,問題是我想一個「全民」值0,選擇添加默認負載選擇?
確實在軌select_tag 3支持呢?
感謝
只需在您的select_tag
一個:include_blank => 'All People'
選項:
<%= select_tag "people", options_from_collection_for_select(@people, "id", "name"), :include_blank => 'All People' %>
`:include_blank =>「All people」`生成以下代碼:``。也許他們改變了語法或什麼? – imjp 2011-07-16 21:15:39
也許multiple_select_tag可能更合適,而不是全的? – EnabrenTane 2011-01-08 04:05:13