Rails: Custom text for rails form_for label

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.


You can specify custom label text via i18n. In config/locales/en.yml, and assuming your user model is named user, you can add the following:

helpers:
    label:
      user:
        name: Your Name

This will allow you to keep using

<%= f.label :name %>

without having to hardcode Your Name.

For more information about i18n, see this. Documentation on the label refer to this.