Flowdock
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.

Data attributes

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

Examples

submit_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", data: { disable_with: "Please wait..." }
# => <input name="commit" data-disable-with="Please wait..." type="submit" value="Complete sale" />

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

submit_tag "Edit", class: "edit_button"
# => <input class="edit_button" name="commit" type="submit" value="Edit" />

submit_tag "Save", data: { confirm: "Are you sure?" }
# => <input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />
Show source
Register or log in to add new notes.
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.." %>
June 7, 2012 - (>= v3.2.3)
1 thank

:disable_with is deprecated

Or you can use this way:

<%= submit_tag "Login", data: { disable_with: "Please wait.." } %>