【问题标题】:Adding links to simple_form hints?添加指向 simple_form 提示的链接?
【发布时间】:2013-01-28 20:06:30
【问题描述】:

有没有办法在来自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) }

【问题讨论】:

  • 这个问题不清楚,也不能理解为这里问的问题。除此之外,没有任何代码或您尝试过的其他内容。
  • 我建议您在遇到困难时附上快照或​​发布代码,以便其他人回答。
  • @SaurabhJain 希望最后的编辑有所帮助

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


【解决方案1】:

您所需要的只是插值。

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

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

【讨论】:

  • 哇,谢谢你,有时最简单的东西会变得最难。老实说,我已经被这个问题困扰了一段时间......谢谢!
  • 没问题,很高兴听到我为您节省了一些时间。现在您可以再次专注于更难的事情了。
  • 对我来说这不起作用,我需要将字符串传递给 raw 就像这里所说的:github.com/plataformatec/simple_form/issues/965
  • 我不得不像这样在它上面贴一个 .html_safe &lt;%= f.input :password, hint: "#{link_to 'Forgot your password?', new_password_path(resource_name)}".html_safe %&gt;
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-15
  • 2020-12-11
  • 2015-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多