Eleeist
Eleeist

Reputation: 7041

Change field form field label

I have a code that generates a form for me:

<%= form_for(@member) do |f| %>
    <%= f.label :email %>
    <%= f.text_field :email %>
<% end %>

I would like to customize the label for this field, ie. set a non-default one.

How would I do that?

Upvotes: 4

Views: 4189

Answers (2)

Ionut Hulub
Ionut Hulub

Reputation: 6326

umm maybe replace f.label :email with f.label :email, "whatever"?

Upvotes: 0

jdoe
jdoe

Reputation: 15771

You could be tempted to replace f.label :email with f.label "whatever", but this'll put you in troubles: you won't be able to use your label for quick access to your text field by clicking on the label's area. Make it this way:

<%= f.label :email, "Something" %>

You text field and label will be associated, but the last one just will be having a different representation a page.

Upvotes: 9

Related Questions