Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: How to change the text on the submit button in a Rails Form

i have listed my _form.html.erb file below what i would like to do is change the text on the submit button i know how to do it in html but not shure how to do it in Rails 3

%= form_for(@faq) do |f| %>   <% if @faq.errors.any? %>     <div id="error_explanation">       <h2><%= pluralize(@faq.errors.count, "error") %> prohibited this faq from being saved:</h2>        <ul>       <% @faq.errors.full_messages.each do |msg| %>         <li><%= msg %></li>       <% end %>       </ul>     </div>   <% end %>    <div class="field">     <%= f.label :question %><br />     <%= f.text_field :question %>   </div>   <div class="field">     <%= f.label :answer %><br />     <%= f.text_area :answer %>   </div>   <div class="actions">     <%= f.submit %>   </div> <% end %> 
like image 883
Rod Nelson Avatar asked Jan 22 '11 17:01

Rod Nelson


People also ask

How do you change the text of a submit button in a form?

Input value attribute The value attribute can be used to change the text of the form submit button. Use value attribute within <input> of type="submit" to rename the button.

Does the submit button go inside the form?

Yes, structurally the submit button needs to be inside a form element for the document to be valid X/HTML.


2 Answers

instead of

<%= f.submit  %> 

put

<%= f.submit "My Submit Text" %> 
like image 197
Andrei S Avatar answered Oct 19 '22 22:10

Andrei S


If you want to change all create and update form submit tags, this change is easy to make. Modify config/locales/en.yml like so:

en:   helpers:     submit:       create: "Crear un %{model}"       update: "Confirmar cambios al %{model} creado" 
like image 42
daniel Avatar answered Oct 19 '22 23:10

daniel