2014-10-09 62 views
1
<%= f.input :body, 'Send Update:' %> 

這會返回一個符號到整數錯誤。Simple_form_for自定義標籤

我需要被標題爲「發送更新:」而不是「身體」

+0

您的意思是標題?它的名字應該是send_update? – 2014-10-09 20:31:42

+0

在my:updates表中,該列稱爲body。但是,當用戶轉到表單時,我希望該文本框標記爲「發送更新」或其他內容。 – 2014-10-09 20:32:39

+0

類似的東西?:發送更新:[繼承你的f.input]? – 2014-10-09 20:33:22

回答

1

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 %> 
2

也許你正在尋找它的標籤/文本先於您的輸入?你可以把它寫在純文本,假設你的看法是html.erb文件:(使用表顯示方便)

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

或者使用f.label

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

更新:做一些研究,發現這也可以工作:

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

不,這只是創建一個表。我正在使用simple_form_for。而不是Form_for。 – 2014-10-09 20:43:42

+0

我說過使用「表」是爲了方便顯示。它完全可選。 – 2014-10-09 20:44:56

+1

更新做到了。我猜猜我以前忘了一個逗號或什麼的。非常感謝奧斯卡獎! – 2014-10-09 20:48:19