Search code examples
ruby-on-railsrubysimple-form

How to change label of simple form input


I Have a code in my project like

<div class="form-inputs">
  <%= f.input :twitter %>
</div>

It gives label as Twitter in my website. How it produce label with out giving label parameter. I want to change label to something else like Tweet it.


Solution

  • You can add label in very simple way

    <%= f.input :twitter, label: 'Tweet it' %>
    

    Check this simple_form usage

    If you want to disable label

    <%= f.input :input_field_name, label: false %>
    

    Add custom class to label

    <%= f.input :field_name, label_html: { class: 'my_class' } %>