Module: RailsBootstrapHelpers::Helpers::FormTagHelper

Included in:
ButtonHelper
Defined in:
lib/rails-bootstrap-helpers/helpers/form_tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#bs_button_tag(value, type, options = {}, &block) ⇒ Object

Renders a Bootstrap button tag. This method behaves just as button_tag but will render a Bootstrap styled button tag instead.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :style (String, Symbol)

    the style of the button

  • :size ("large", "small", "mini")

    the size of the button

  • :disabled (Boolean) — default: false

    if the button should be disabled or not

  • :icon (String)

    the name of an icon to render on the button

  • :icon_position ("left", "right") — default: "left"

    the post of the icon, if present

  • :icon_invert (Boolean) — default: left

    if the color of the icon should be inverted



17
18
19
20
# File 'lib/rails-bootstrap-helpers/helpers/form_tag_helper.rb', line 17

def bs_button_tag (value, type, options = {}, &block)
  options = options.merge type: type
  RailsBootstrapHelpers::Renderers::ButtonRenderer.new(self, :button, value, options, &block).render
end

#bs_submit_tag(value, options = {}) ⇒ Object

Renders a Boolean submit tag. This method behaves just as submit_tag but will render a Bootstrap styled submit tag instead.

All the other options are passed straight through to the underlying submit_tag method.

Parameters:

  • value (String)

    the text of the submit tag

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

    a hash of options

Options Hash (options):

  • :style (String, Symbol)

    the style of the button

  • :size ("large", "small", "mini")

    the size of the button



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rails-bootstrap-helpers/helpers/form_tag_helper.rb', line 33

def bs_submit_tag (value, options = {})
  options = options.dup

  if options[:class].present?
    options[:class] << " "
  else
    options[:class] = ""
  end

  options[:class] << "btn"

  if style = options.delete(:style)
    options[:class] << " btn-" + style.to_s
  end

  if size = options.delete(:size)
    options[:class] << " btn-" + size.to_s
  end

  submit_tag value, options
end