module SimpleForm::Bootstrap::FormBuilders::Button

Constants

BUTTON_CLASSES

Public Instance Methods

button(type, *args, &proc) click to toggle source

Adds the btn-default class selectively to buttons which do not have an explicit button type.

Calls superclass method
# File lib/simple_form/bootstrap/form_builders/button.rb, line 6
def button(type, *args, &proc)
  options = args.extract_options!.dup
  options[:class] = [*options[:class]]

  # Add the specified class type.
  if options[:class].select { |cls| BUTTON_CLASSES.include?(cls) }.empty?
    if type.to_s == :submit.to_s.freeze
      options[:class] << 'btn-primary'
    else
      options[:class] << 'btn-default'
    end
  end
  args << options

  super(type, *args, &proc)
end
submit_button(*args, &block) click to toggle source

Creates a submit button.

This augments the original button implementation to generate a button element with a submit action when a block is given. Otherwise, it falls back to the original submit helper.

# File lib/simple_form/bootstrap/form_builders/button.rb, line 28
def submit_button(*args, &block)
  if block_given?
    options = args.extract_options!.dup
    options[:type] = :submit
    options[:name] ||= 'commit'
    args << options
    button_button(options, &block)
  else
    submit(*args)
  end
end