Class: Forme::Wrapper::Bootstrap3
- Inherits:
-
Forme::Wrapper
- Object
- Forme::Wrapper
- Forme::Wrapper::Bootstrap3
- Defined in:
- lib/forme/bs3.rb
Overview
Wraps inputs with <div class=“form-group”>
Instance Method Summary collapse
-
#call(tag, input) ⇒ Object
Wrap the input in the tag of the given type.
Instance Method Details
#call(tag, input) ⇒ Object
Wrap the input in the tag of the given type.
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# 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 |