Class: Forme::InputsWrapper::Table

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

Overview

Use a <table> tag to wrap the inputs.

Registered as :table.

Instance Method Summary collapse

Instance Method Details

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

Wrap the inputs in a <table> tag.



1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
# File 'lib/forme.rb', line 1292

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

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

    yield
  end
end