ruby-on-rails 如何让select_tag在参数前面显示文本?

insrf1ej  于 2022-11-19  发布在  Ruby
关注(0)|答案(1)|浏览(220)

我想显示“年份:“的参数字段。如何将文本追加到参数字段中?
我使用的select_tag如下所示:

<%= form_tag results_path, :method => 'get' do %>
   <%= select_tag :season_year, options_for_select(@tournaments.order(season_year: :desc).collect{ |u| [u.season_year] }.uniq, session[:season_year]), class: "btn btn-outline-primary", :onchange => "this.form.submit();" %>
   <%= select_tag :tournament, options_for_select(@tournaments_filtered.order(tournament_date: :desc).collect{ |u| [u.lake_name, u.id] }, session[:tournament]), class: "btn btn-outline-primary", :onchange => "this.form.submit();" %>
   <%= select_tag :table_select, options_for_select(@result_options, session[:table_select]), class: "btn btn-outline-primary", :onchange => "this.form.submit();" %>
<% end %>

oxcyiej7

oxcyiej71#

可以使用include_blank选项添加 dud 选项。
即添加include_blank: "Year:"
有关详细信息,请参阅docs

相关问题