Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 468
Eleeist Avatar asked Feb 19 '23 00:02

Eleeist


1 Answers

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.

like image 109
jdoe Avatar answered Feb 27 '23 15:02

jdoe