繁体   English   中英

options_from_collection_for_select 的下拉列表中为空白

[英]Blank in drop-down list in options_from_collection_for_select

我想使用 options_from_collection_for_select 在我的下拉列表中包含一个空白,但似乎无法放入通常的集合参数{ :include_blank => true} 我在任何地方都找不到这方面的参考。 我错过了什么吗? 我的说法是:

<%= select_tag "search", options_from_collection_for_select(TaskGroup.all.order("LOWER(task_group_name)"), "id", "task_group_name",params[:search]) %>

提前感谢您的帮助,

利亚

试试这个:

<%= 
  select_tag( 
    "search",
    options_from_collection_for_select(
      TaskGroup.all.order("LOWER(task_group_name)"), "id", "task_group_name",params[:search]
    ), 
    :include_blank => true 
  )
%>

试试这个:

<%= select_tag "search", options_for_select(TaskGroup.all.order("LOWER(task_group_name)").map {|task_group| [task_group.task_group_name, task_group.id]}, params[:search]), {include_blank: "Select task group"} %>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM