image_submit_tag(source, options = {}) public

Displays an image which when clicked will submit the form.

source is passed to AssetTagHelper#path_to_image


  • :confirm => 'question?' - This will add a JavaScript confirm prompt with the question specified. If the user accepts, the form is processed normally, otherwise no action is taken.

  • :disabled - If set to true, the user will not be able to use this input.

  • Any other key creates standard HTML options for the tag.


# => <input src="/images/login.png" type="image" />

image_submit_tag("purchase.png", :disabled => true)
# => <input disabled="disabled" src="/images/purchase.png" type="image" />

image_submit_tag("search.png", :class => 'search_button')
# => <input class="search_button" src="/images/search.png" type="image" />

image_submit_tag("agree.png", :disabled => true, :class => "agree_disagree_button")
# => <input class="agree_disagree_button" disabled="disabled" src="/images/agree.png" type="image" />
Show source
Register or log in to add new notes.
October 29, 2008
3 thanks

A work-around for adding confirmation to image_submit_tag

Sometimes you may want to add a confirmation to image submit tags but this function does not allow it. To get over this limitation use a normal submit tag and set the src and type properties (set type to “image”)

Code example

submit_tag “Delete”, :confirm => “Are you sure?”, :src => “/images/trash.png”, :type => “image” %>

January 24, 2009
0 thanks

Adding "alt" text to the image tag

<%= image_submit_tag (“create.gif”, :alt => “Create new entity”) %>

This way when the images are disabled or don’t work you get the nice custom text instead of the standard one. Pretty useful.