Method: Bootstrap::FormHelper#cancel_button_tag

Defined in:
app/helpers/bootstrap/form_helper.rb

#cancel_button_tag(text, type, size, options = {}) ⇒ String

Convenience method for standard “Cancel” button.

The text, type, and size arguments are all optional.

Has same semantics as calls to ButtonHelper#button except:

  • text defaults to “Cancel”

  • :url option is required

Examples:

cancel_button_tag(url: '/')
cancel_button_tag('Go Back', url: '/')
cancel_button_tag(:info, url: '/')
cancel_button_tag(:large, url: '/')
cancel_button_tag('Return', :small, :warning, url: '/', id: 'my-id')

Parameters:

  • text (String)

    text of link

  • type (Symbol)

    type of button

  • size (Symbol)

    size of button

  • options (Hash) (defaults to: {})

    All keys except :url become html attributes of the <a> tag

Options Hash (options):

  • :url (String)

    required

Returns:

  • (String)

    <a> tag styled as Bootstrap button

Raises:



33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/bootstrap/form_helper.rb', line 33

def cancel_button_tag(*args)
  options = canonicalize_options(args.extract_options!)
  raise(ArgumentError, "must pass a :url option") unless options.has_key?(:url)
  options = ensure_class(options, 'btn')
  
  args.map!(&:to_s)
  args.unshift("Cancel") if args.all? { |e| ::Bootstrap::ButtonHelper::BUTTON_ALL.include?(e) }

  button(*args, options)
end