class Forme::Wrapper::Bootstrap3

  1. lib/forme/bs3.rb
Superclass: Wrapper

Wraps inputs with <div class=“form-group”>

Methods

Public Instance

  1. call

Public Instance methods

call (tag, input)

Wrap the input in the tag of the given type.

[show source]
# File lib/forme/bs3.rb, line 304
def call(tag, input)
  attr = input.opts[:wrapper_attr] ? input.opts[:wrapper_attr].dup : { }
  klass = attr[:class] ? attr[:class].split(' ').unshift('form-group').uniq : ['form-group']
  
  case input.type
  when :submit, :reset
    klass.delete('form-group')
    attr[:class] = klass.sort.uniq.join(' ').strip
    attr.delete(:class) if attr[:class].empty?
    [tag]
  when :radio, :checkbox
    klass.delete('form-group')
    klass.unshift( input.type.to_s )
    attr[:class] = klass.sort.uniq.join(' ').strip
    [input.tag(:div, attr, tag)]
  when :hidden
    super
  else
    attr[:class] = klass.sort.uniq.join(' ').strip
    [input.tag(:div, attr, [tag])]
  end

end