Reputation: 4855
I have this code:
<div class="export-buttons">
<div class="row">
<div class="col-lg-offset-4">
<%= label_tag :year, "Any" %>
<%= select_tag :year,options_for_select((2014..2040).map{|x| x.to_s}),name:"params[year]" %>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-lg-offset-4">
<%= link_to "Revenue summary", revenue_summary_path(format:"pdf"),class:"btn btn-bg btn-default", role:"button" %>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-lg-offset-4">
<%= link_to "Fees summary", fees_summary_path(format:"pdf"),class:"btn btn-bg btn-default", role:"button" %>
</div>
</div>
</div>
And I would like to pass the selected value in the select_tag
to params
. However I do not have a form_tag
, hence there's no Submit
button either.
Is there a way to "embed" it inside the params
hash? Or do I need a form_tag
for sure? In case of the latter, what would be the best approach, two submit-buttons + one path + if/else @controller?
Upvotes: 1
Views: 550
Reputation: 9362
If you really want to avoid form tags, which may seems logical too since you want to have multiple download links which would simply send out an additional parameter of select_tag to the backend. You can use javascript for same.
Upvotes: 1