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