rottendevice rottendevice - 1 year ago 73
Ruby Question

Adding a submit button image to a Rails form

I'm creating a form in Rails for submitting comments, and I want the submit button to be an image, rather than an HTML button. In this bit of documentation, it says the code is

, but I can't get it to work in my code.

Here's what I'm working with:

<% form_for [@post,], :remote => true do |f| %>
<%= f.label :body, "Add a comment" %><br />
Name <%= f.text_field :name %><br />
Website<%= f.text_field :website %><br />
Twitter<%= f.text_field :twitter %><br />
<%= f.text_area :body %>
<div id="comment-form">

<div id="comment-button"><p>
<%= f.image_submit_tag("comment-button.png") %></p>
<% end %>

Thanks for the help.

Answer Source

You can do it like so:


<%= f.submit "" %>