Class: Forme::Wrapper::Bootstrap3

Inherits:
Forme::Wrapper show all
Defined in:
lib/forme/bs3.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#call(tag, input) ⇒ Object

Wrap the input in the tag of the given type.



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/forme/bs3.rb', line 317

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
    [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