Graham Slick
Graham Slick

Reputation: 6870

Change form_for submit label without changing passed parameter

I have two submit button for my form_for: one is to save as draft, the other one is to publish. To deal with post's status (published or draft), I did this:

 <%= f.submit "published", class: 'form-control' name: "status"  %>
 <%= f.submit "draft", class: 'form-control', name: "status" %>

I pass the "status" parameter, and it takes as value either "published" or "draft". The issue is that the value is the label of the button. I'd like to change the label, but not the value. I tried to add:

label: "My label"

to each button but didn't seem to work.

How could I do this ?

Upvotes: 0

Views: 56

Answers (1)

Marco Roth
Marco Roth

Reputation: 184

This could be one way, but I think this is not the best one

<%= f.button "My Label", as: :submit, class: 'form-control' name: "status", value: "published"  %>

Upvotes: 1

Related Questions