Simple_form: Allow HTML in hints with strings

Created on 21 Dec 2013  路  2Comments  路  Source: heartcombo/simple_form

It looks like the hint generation now escapes any html in a hint that is a string, which is causing issues for certain things for example embedding a link within a hint string. I.E.:

<%= simple_form_for @user do |f| %>
  <%= f.input :username, label: 'Your username please' %>
  <%= f.input :password, hint: "Reset your password #{link_to('here', password_reset_url) }." %>
  <%= f.button :submit %>
<% end %>

Generates the hint out like:

Reset your password <a href="https://localhost:3000/passwords/edit">here</a>.

Instead of the intended:
Reset your password here.

Since this looks intentional from the commit I wanted to get feedback about handling something of this sort. Perhaps there could be an option added that allows you to explicitly turn off html escaping? I would be happy to submit a pull request based on your feedback.

Thanks in advance!

Most helpful comment

If you know and trust the string you can do:

<%= f.input :password, hint: raw("Reset your password #{link_to('here', password_reset_url) }.") %>

And everything will work fine

All 2 comments

If you know and trust the string you can do:

<%= f.input :password, hint: raw("Reset your password #{link_to('here', password_reset_url) }.") %>

And everything will work fine

That worked great thank you!

Was this page helpful?
0 / 5 - 0 ratings