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
300 def call(tag, input)
301   attr = input.opts[:wrapper_attr] ? input.opts[:wrapper_attr].dup : { }
302   klass = attr[:class] ? attr[:class].split(' ').unshift('form-group').uniq : ['form-group']
303   
304   case input.type
305   when :submit, :reset
306     klass.delete('form-group')
307     attr[:class] = klass.sort.uniq.join(' ').strip
308     attr.delete(:class) if attr[:class].empty?
309     [tag]
310   when :radio, :checkbox
311     klass.delete('form-group')
312     klass.unshift( input.type.to_s )
313     attr[:class] = klass.sort.uniq.join(' ').strip
314     [input.tag(:div, attr, tag)]
315   when :hidden
316     super
317   else
318     attr[:class] = klass.sort.uniq.join(' ').strip
319     [input.tag(:div, attr, [tag])]
320   end
321 
322 end