Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the automatic text generated from f.label

I have the code

<%= form_for(@user) do |f| %>
    <div>
    <%= f.label :email, :class=>'inline betaLabelTextField' %>
    <%= f.text_field :email, :class=>'betaTextField' %>
    </div>
<% end %>

The problem is that this code automatically generates the html

<div> 
        <label class="inline betaLabelTextField" for="user_email">Email</label> 
        <input class="betaTextField" id="user_email" name="user[email]" size="30" type="text" /> 
    </div> 

Inside a form. How can i change 'Email' to 'Email Address'?

like image 743
Vasseurth Avatar asked Jul 09 '11 19:07

Vasseurth


2 Answers

This is done by adding appropriate i18n values to config/locale/en.yml. Please have a look at the guides at http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models for the format of that file for active record values.

like image 60
moritz Avatar answered Nov 09 '22 09:11

moritz


The easiest way is to do this instead:

<%= form_for(@user) do |f| %>
    <div>
    <%= f.label :email, "Email Address", :class=>'inline betaLabelTextField' %>
    <%= f.text_field :email, :class=>'betaTextField' %>
    </div>
<% end %>
like image 21
sarahhodne Avatar answered Nov 09 '22 11:11

sarahhodne