添加simple_form提示的链接?

时间:2013-02-13 09:59:34

标签: ruby-on-rails simple-form hint

有没有办法在simple_form表单中的特定输入内部提示链接?

例如 - “忘记密码?”在密码的输入提示中。

这样可以避免某些样式将链接附加到输入框。

可能是一个愚蠢的问题,但我无法弄清楚如何做到这一点:/

提前致谢。

编辑(这种语法错误,但希望它能说明我想说的内容,特别是第3行):

=simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
    =f.input :email, placeholder: "me@example.com"                             
    =f.input :password, hint: { link_to "Forgot your password?", new_password_path(resource_name) }

1 个答案:

答案 0 :(得分:17)

你需要的只是插值。

<%= f.input :password, hint: "#{link_to 'Forgot your password?', new_password_path(resource_name)}" %>

这将在提示中插入您的代码。在这种情况下,忘记了密码链接。