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
314 def call(tag, input)
315   attr = input.opts[:wrapper_attr] ? input.opts[:wrapper_attr].dup : { }
316   klass = attr[:class] ? attr[:class].split(' ').unshift('form-group').uniq : ['form-group']
317   
318   case input.type
319   when :submit, :reset
320     klass.delete('form-group')
321     attr[:class] = klass.sort.uniq.join(' ').strip
322     attr.delete(:class) if attr[:class].empty?
323     [tag]
324   when :radio, :checkbox
325     klass.delete('form-group')
326     klass.unshift( input.type.to_s )
327     attr[:class] = klass.sort.uniq.join(' ').strip
328     [input.tag(:div, attr, tag)]
329   when :hidden
330     super
331   else
332     attr[:class] = klass.sort.uniq.join(' ').strip
333     [input.tag(:div, attr, [tag])]
334   end
335 
336 end