문제

Is there a way to have a link inside a hint from an specific input within a simple_form form?

For example- "Forgot your password?" in passwords' input hint.

This way some styling could be avoided to attach the link to the input box.

May be a stupid question but I can't figure out how to do it :/

Thanks in advance.

Edit (This syntax is wrong, but hope it gives the idea on what I am trying to say, specifically in line 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) }
도움이 되었습니까?

해결책

All you need is interpolation.

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

This will insert your code within the hint. In this case a forgotten password link.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top