submit_tag(value = "Save changes", options = {})
Instance Public methods
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?" />
Please login to continue.