Reputation: 6363
I have the following form_for in my rails project that allows a user to upload a file and then click submit. As of now they are standard buttons. I would like to use an icon image for the "choose your file" button. Is there a way to keep the functionality of that button, but instead make it an image that the user can click on to upload their file?
<%= form_for@user, :url => users_upload_path, multipart: true, method: :post do |f| %>
<%= f.file_field :name %> <%= f.submit %>
Thanks!
Upvotes: 0
Views: 1093
Reputation: 3803
<%= f.submit "Comment", :type => :image, :src => "/images/comment-button.png" %>
OR
<%= image_submit_tag("login.png") %>
http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-image_submit_tag
try this
Upvotes: 1