I'd like to include a blank in my drop-down list using options_from_collection_for_select but cannot seem to put in the usual collection parameter { :include_blank => true}
. I cannot find a reference for this anywhere. Am I missing something? My statement is:
<%= select_tag "search", options_from_collection_for_select(TaskGroup.all.order("LOWER(task_group_name)"), "id", "task_group_name",params[:search]) %>
Thanking you in advance for your help,
Leah
Try this:
<%=
select_tag(
"search",
options_from_collection_for_select(
TaskGroup.all.order("LOWER(task_group_name)"), "id", "task_group_name",params[:search]
),
:include_blank => true
)
%>
Try this:
<%= 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"} %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With