image_submit_tag
![Wide documentation Importance_3](https://d2vfyqvduarcvs.cloudfront.net/images/importance_3.png?1349367920)
image_submit_tag(source, options = {})
public
Displays an image which when clicked will submit the form.
source is passed to AssetTagHelper#path_to_image
Options
-
: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.
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" />
![Default_avatar_30](https://www.gravatar.com/avatar/6cf87365e668b95f086c1348c5c35bdc?size=30&default=http://apidock.com/images/default_avatar_30.png)
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” %>
![Default_avatar_30](https://www.gravatar.com/avatar/bab1a2e4449e412ede5696e9b2539c55?size=30&default=http://apidock.com/images/default_avatar_30.png)
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.