class Forme::InputsWrapper::Table

  1. lib/forme/transformers/inputs_wrapper.rb
Superclass: Object

Use a <table> tag to wrap the inputs.

Registered as :table.

Methods

Public Instance

  1. call

Public Instance methods

call (form, opts, &block)

Wrap the inputs in a <table> tag.

[show source]
# File lib/forme/transformers/inputs_wrapper.rb, line 82
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