Class: Miniform::Field

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

Instance Method Summary collapse

Constructor Details

#initialize(builder, name, options, &block) ⇒ Field

Returns a new instance of Field.



3
4
5
6
7
8
# File 'lib/miniform/field.rb', line 3

def initialize(builder, name, options, &block)
  @builder = builder
  @name = name
  @options = options
  @block = block
end

Instance Method Details

#renderObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/miniform/field.rb', line 10

def render
  if should_omit_label?
    @block.call + help_block
  else
    @builder.form_group(@name) do
      if vertical?
        label + @block.call + help_block
      else
        label + input_wrapper { @block.call + help_block  }
      end
    end
  end
end