Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Custom text for rails form_for label

I want to display a label in form_for:

<div class="field">   <%= f.label :name %><br />   <%= f.text_field :name %> </div> 

This generates the label "Name", but I want it to be "Your Name". How can I change it?

like image 692
Paul S. Avatar asked Oct 22 '12 00:10

Paul S.


1 Answers

The second parameter to label helper will allow you to set custom text.

<%= f.label :name, 'Your Name' %> 

Use Ruby on Rails Documentation to look up helper methods.

like image 142
gylaz Avatar answered Oct 01 '22 10:10

gylaz