image_submit_tag(source, options = {}) public

Displays an image which when clicked will submit the form.

source is passed to AssetTagHelper#image_path

Options

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

Examples

  image_submit_tag("login.png")
  # => <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.