submit_tag(value = "Save changes", options = {}) public

Creates a submit button with the text value as the caption.


  • :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 true, the user will not be able to use this input.
  • :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.
  • Any other key creates standard HTML options for the tag.


  # => <input name="commit" type="submit" value="Save changes" />

  submit_tag "Edit this article"
  # => <input name="commit" type="submit" value="Edit this article" />

  submit_tag "Save edits", :disabled => true
  # => <input disabled="disabled" name="commit" type="submit" value="Save edits" />

  submit_tag "Complete sale", :disable_with => "Please wait..."
  # => <input name="commit" onclick="this.disabled=true;this.value='Please wait...';this.form.submit();"
  #    type="submit" value="Complete sale" />

  submit_tag nil, :class => "form_submit"
  # => <input class="form_submit" name="commit" type="submit" />

  submit_tag "Edit", :disable_with => "Editing...", :class => "edit-button"
  # => <input class="edit-button" onclick="this.disabled=true;this.value='Editing...';this.form.submit();"
  #    name="commit" type="submit" value="Edit" />
Show source
Register or log in to add new notes.
June 7, 2012
2 thanks

:disable_with is deprecated

Or you can use this way:

<%= submit_tag "Login", data: { disable_with: "Please wait.." } %>
June 5, 2012
1 thank

: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.." %>
January 14, 2015
0 thanks

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]')