Reputation: 1447
I have a form with two submit
buttons, each sending different parameters. The first should read "Save for Later" and the other should say "Submit for Consideration".
However, they are currently displaying the value of the parameter being sent, not the text. I've tried the following options, all with the same result:
<%= f.button :submit, "Save for Later", name: "application_status_id", value: 2, class: "btn btn-light" %>
<%= f.button :submit, "Submit for Consideration", name: "application_status_id", value: 3, class: "btn btn-primary" %>
Which was the same result as:
<%= f.submit "Save for Later", name: "application_status_id", value: 2, class: "btn btn-light" %>
<%= f.submit "Submit for Consideration", name: "application_status_id", value: 3, class: "btn btn-primary" %>
And I also tried using a do
/end
structure, but got the same result.
How do I get these to show the text instead of the values?
Upvotes: 0
Views: 449
Reputation: 15838
I wouldn't use f.submit
since it tries to set the text based on the model state https://apidock.com/rails/ActionView/Helpers/FormBuilder/submit.
I wouldn't use submit_tag
either since inputs with type submit uses the "value" value as the text. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit
Use two button tags instead with type "submit":
<%= button_tag "Save for Later", type: 'submit', name: "application_status_id", value: 2, class: "btn btn-light" %>
<%= button_tag "Submit for Consideration", type: 'submit', name: "application_status_id", value: 3, class: "btn btn-primary" %>
https://apidock.com/rails/v5.2.3/ActionView/Helpers/FormTagHelper/button_tag
Upvotes: 1