v3.2.3 - Show latest stable - 0 notes - Class: ActionView::Helpers::FormTagHelper
button_tag(content_or_options = nil, options = nil, &block) public

Creates a button element that defines a submit button, resetbutton or a generic button which can be used in JavaScript, for example. You can use the button tag as a regular submit tag but it isn’t supported in legacy browsers. However, the button tag allows richer labels such as images and emphasis, so this helper will also accept a block.


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

  • :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. This feature is provided by the unobtrusive JavaScript driver.

  • Any other key creates standard HTML options for the tag.


# => <button name="button" type="submit">Button</button>

button_tag(:type => 'button') do
  content_tag(:strong, 'Ask me!')
# => <button name="button" type="button">
#     <strong>Ask me!</strong>
#    </button>

button_tag "Checkout", :disable_with => "Please wait..."
# => <button data-disable-with="Please wait..." name="button" type="submit">Checkout</button>
Show source
Register or log in to add new notes.