image_submit_tag(source, options = {}) public

Displays an image which when clicked will submit the form.

source is passed to AssetTagHelper#path_to_image


  • :data - This option can be used to add custom data attributes.

  • :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.

Data attributes

  • 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.


# => <input alt="Login" src="/assets/login.png" type="image" />

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

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

image_submit_tag("agree.png", disabled: true, class: "agree_disagree_button")
# => <input alt="Agree" class="agree_disagree_button" disabled="disabled" src="/assets/agree.png" type="image" />

image_submit_tag("save.png", data: { confirm: "Are you sure?" })
# => <input alt="Save" src="/assets/save.png" data-confirm="Are you sure?" 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.