R.J. Robinson
R.J. Robinson

Reputation: 2240

Simple_form_for custom label

<%= f.input :body, 'Send Update:' %>

This returns a Symbol to Integer error.

I need the box to be titled 'Send Update:' and not 'Body'

Upvotes: 1

Views: 1659

Answers (2)

Oscar Valdez Esquea
Oscar Valdez Esquea

Reputation: 920

Perhaps what you are looking for its for a label/text to precede your input? You could write it on plain text, assuming your view is an html.erb file: (using table for display convenience)

<table>
 <tr>
  <td>Send Update: </td>
  <td><%= f.input :body %></td>
 </tr>
</table>

Or use the f.label:

<table>
 <tr>
  <td><%= f.label :body, "Send Update:" %></td>
  <td><%= f.input :body %></td>
 </tr>
</table>   

UPDATE: Doing some research, found out that this could work too:

<%= f.input :body, label: "Send Update:" %>

Upvotes: 2

Alexander
Alexander

Reputation: 2568

From documentation:

<%= simple_form_for @user do |f| %>
  <%= f.input :username, label: 'Your username please' %>
  <%= f.input :remember_me, inline_label: 'Yes, remember me' %>
  <%= f.input :email, label_html: { class: 'my_class' } %>
  <%= f.input :password_confirmation, label: false %>

  <%= f.button :submit %>
<% end %>

Upvotes: 3

Related Questions