Method: Bootstrap::FormHelper#submit_button_tag

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

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

Returns <input> similar to #submit_tag() but: x

  • styled like a Bootstrap button, type :primary

  • has :disable_with set to “Processing …”

See ButtonHelper for documentation on button type and size

submit_button_tag('Save')
submit_button_tag('Delete', :danger)
submit_button_tag('Big', :large)
submit_button_tag('With Options', :small, :info, id: 'my-id')

Options Hash (options):

  • :disable_with (String, false)

    either override or turn off the disabling of the button



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/helpers/bootstrap/form_helper.rb', line 72

def submit_button_tag(*args)
  options = canonicalize_options(args.extract_options!)
  
  value = if Bootstrap::ButtonHelper::BUTTON_ALL.include?(args.first.to_s)
    "Save changes"
  else
    args.shift.presence || "Save changes"
  end

  button_classes = if args.present?
    args.each { |e| raise(InvalidButtonModifierError, e.inspect) unless
       Bootstrap::ButtonHelper::BUTTON_ALL.include?(e.to_s) }
    ['btn'] + args.map { |e| "btn-#{e}" }
  else
    ['btn', 'btn-primary']
  end
  options = ensure_class(options, button_classes)

  disable_or_remove = options[:data] && options[:data].delete(:disable_with)

  unless disable_or_remove === false
    options[:data] ||= {}
    options[:data][:disable_with] = disable_or_remove || "Processing ..."
  end

  submit_tag(value, options)
end