Class: Forme::InputsWrapper

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

Overview

Default inputs_wrapper used by the library, uses a <fieldset>.

Registered as :default.

Direct Known Subclasses

FieldSetOL

Defined Under Namespace

Classes: Div, FieldSetOL, OL, TR, Table

Instance Method Summary collapse

Instance Method Details

#call(form, opts) ⇒ Object

Wrap the inputs in a <fieldset>. If the :legend option is given, add a <legend> tag as the first child of the fieldset.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/forme/transformers/inputs_wrapper.rb', line 11

def call(form, opts)
  attr = opts[:attr] ? opts[:attr].dup : {}
  Forme.attr_classes(attr, 'inputs')
  if legend = opts[:legend]
    form.tag(:fieldset, attr) do
      form.emit(form.tag(:legend, opts[:legend_attr], legend))
      yield
    end
  else
    form.tag(:fieldset, attr, &Proc.new)
  end
end