添加当前值作为占位符

时间:2014-07-02 11:49:48

标签: html ruby-on-rails haml formtastic

在我的控制器中我有

MessageContent.new(language: "en", body: "Write your english text here", title: "", sender: "Admin")

并且在视图中,我想将body作为占位符添加到我的输入

 = f.input :body

我一直在寻找答案,但没有任何线索。 THX

1 个答案:

答案 0 :(得分:1)

这应该有效

# controller
@message_content = MessageContent.new(language: "en", body: "Write your english text here", title: "", sender: "Admin")

# view
= f.input :body, placeholder: @message_content.body