I have two submit_tag on my form and I would like to send a different parameter on each. How can I do this?
My form view:
<%= form_tag(some_path, :method => "get") do %>
<%= text_field_tag :number %>
<%= text_field_tag :name %>
<%= submit_tag "Op01", class: "btn_search", my_parameter: 1 %>
<%= submit_tag "Op02", class: "btn_search", my_parameter: 2 %>
<% end %>
And on my controller:
@oper_type = params[:my_parameter]
But when I display the @oper_type it is always nil.
Thanks.
<%= submit_tag "Op01", class: "btn_search", value: 1 %>
<%= submit_tag "Op01", class: "btn_search", value: 2 %>
@oper_type = params[:commit] # 1 or 2
or a little simplier
<%= submit_tag "Op01", class: "btn_search" %>
<%= submit_tag "Op01", class: "btn_search" %>
@oper_type = params[:commit] # "Op01" or "Op02"
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