Class: Forme::InputsWrapper::Bs3Table

Inherits:
Object
  • Object
show all
Defined in:
lib/forme/bs3.rb

Overview

Use a <table class=“table”> tag to wrap the inputs.

Registered as :bs3_table.

Instance Method Summary collapse

Instance Method Details

#call(form, opts, &block) ⇒ Object

Wrap the inputs in a <table> tag.



246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/forme/bs3.rb', line 246

def call(form, opts, &block)
  attr = opts[:attr] ? opts[:attr].dup : { :class=>'table table-bordered'}
  form.tag(:table, attr) do
    if legend = opts[:legend]
      form.tag(:caption, opts[:legend_attr], legend)
    end

    if (labels = opts[:labels]) && !labels.empty?
      form.tag(:tr, {}, labels.map{|l| form._tag(:th, {}, l)})
    end

    yield
  end
end