submit_tag
- 1.0.0 (0)
- 1.1.6 (5)
- 1.2.6 (0)
- 2.0.3 (35)
- 2.1.0 (7)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (5)
- 3.0.9 (-2)
- 3.1.0 (0)
- 3.2.1 (-1)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (1)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (9)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (7)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (-38)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
submit_tag(value = "Save changes", options = {})
public
Creates a submit button with the text value as the caption.
Options
-
:data - This option can be used to add custom data attributes.
-
:disabled - If true, the user will not be able to use this input.
-
Any other key creates standard HTML options for the tag.
Examples
submit_tag # => <input name="commit" data-disable-with="Save changes" type="submit" value="Save changes" /> submit_tag "Edit this article" # => <input name="commit" data-disable-with="Edit this article" type="submit" value="Edit this article" /> submit_tag "Save edits", disabled: true # => <input disabled="disabled" name="commit" data-disable-with="Save edits" type="submit" value="Save edits" /> submit_tag nil, class: "form_submit" # => <input class="form_submit" name="commit" type="submit" /> submit_tag "Edit", class: "edit_button" # => <input class="edit_button" data-disable-with="Edit" name="commit" type="submit" value="Edit" />
Deprecated: Rails UJS attributes
Prior to Rails 7, Rails shipped with the JavaScript library called @rails/ujs on by default. Following Rails 7, this library is no longer on by default. This library integrated with the following options:
-
confirm: 'question?' - If present the unobtrusive JavaScript drivers will provide a prompt with the question specified. If the user accepts, the form is processed normally, otherwise no action is taken.
-
:disable_with - Value of this parameter will be used as the value for a disabled version of the submit button when the form is submitted. This feature is provided by the unobtrusive JavaScript driver. To disable this feature for a single submit tag pass :data => { disable_with: false } Defaults to value attribute.
submit_tag “Complete sale”, data: { disable_with: “Submitting…” } # => <input name=“commit” data-disable-with=“Submitting…” type=“submit” value=“Complete sale” />
submit_tag “Save”, data: { confirm: “Are you sure?” } # => <input name=‘commit’ type=‘submit’ value=‘Save’ data-disable-with=“Save” data-confirm=“Are you sure?” />
:disable_with is deprecated
Or you can use this way:
<%= submit_tag "Login", data: { disable_with: "Please wait.." } %>
:disable_with is deprecated
Since version 3.2.5 you should not use :disable_with.
Use this:
<%= submit_tag "Login", 'data-disable-with' => "Please wait.." %>
Have submit_tag send value as a nested resource
To have the submit_tag send it’s value within a nested resource for strong params use the name paramter.
submit_tag("Send", name: 'article[submit]')

