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
82 def call(form, opts, &block)
83   attr = opts[:attr] ? opts[:attr].dup : {}
84   form.tag(:table, attr) do
85     if legend = opts[:legend]
86       form.tag(:caption, opts[:legend_attr], legend)
87     end
88 
89     if (labels = opts[:labels]) && !labels.empty?
90       form.tag(:thead) do
91         form.tag(:tr, {}, labels.map{|l| form._tag(:th, {}, l)})
92       end
93     end
94 
95     form.tag(:tbody) do
96       yield
97     end
98   end
99 end