Search code examples
ruby-on-railsform-helpers

Rails: Embed an image in submit button?


With link_to, we can embed content like this:

<%= link_to '#' do &>
  <img>

By doing so, we could change a text link into other.

However, When using forms, the button is achieve in html using <input>, and I'm unable to replace it like link_to. How can I do something like:

<%= f.submit "#" do %>
  <img>

Solution

  • You should use image_submit tag instead of f.submit