ActionView::Helpers::FormTagHelper

image_submit_tag

API docs (Rails 8.1.4.1) ↗
def image_submit_tag(source, options = {})

Description

Creates an <input type="image"> (an image submit button). Unlike submit_tag, it adds neither name nor data-disable-with.

Arguments

Changing a value updates the ERB and HTML.

Used as the src attribute. Accepts:
  • A URL (a string starting with https:// or another …://, //, data: or cid:): sets src to it as is.
  • A string starting with /: sets src to it as is.
  • Any other string: looks up the asset (a file in app/assets) and uses its path with a hash added to the file name. If the asset is not found, raises Propshaft::MissingAssetError. The lookup and the hash come from Propshaft; in an app without an asset pipeline, /images/ is prepended without a lookup. The extension cannot be left out.
options= {}
true skips the asset lookup and prepends /images/.
"Send"
Sets alt to the given value as is. By default, alt is omitted.
"send"
Sets name to the given value as is. By default, name is omitted (there is no default like submit_tag's commit).
Common options

Rails handles these options the same way in every helper. Options the HTML spec does not allow on the <input>, and ones this site considers rarely used, are not listed here.

Shared by all helpers

true adds disabled="disabled"; false omits it. The same goes for every HTML attribute in Rails' list (BOOLEAN_ATTRIBUTES), such as readonly, required and autofocus: any value other than false or nil adds it as attr="attr".
{active: true, hidden: false}
A hash gives the keys whose values are not false or nil, joined with spaces. An array gives its elements joined with spaces, after removing nil, false and empty strings (including whitespace-only strings).
{controller: "tags", tags_suggestions_value: ["ruby", "rails"]}
A hash adds data-* attributes, with _ in the keys converted to -. Array and hash values are converted to JSON strings.
{describedby: ["name_help", "name_error"], invalid: false}
Like :data, adds aria-* attributes. Array values are joined with spaces, leaving out nil and empty strings (nothing is added if none remain). For a hash value, the keys whose values are not false or nil are joined with spaces.
Any other options become HTML attributes of the <input>; those with a nil value are left out.

ERB

Changes from the previous output: Added Removed Changed


          

HTML


          

Preview

Interacting with the preview updates the form submission.

Form submission

Form data

namevalue
Request body

Content-Type:


              

params


              
Clicking the image in the preview sends the clicked position, named after the name value with .x and .y appended (x and y without a name).