class Miniform::Field
Public Class Methods
new(builder, name, options, &block)
click to toggle source
# File lib/miniform/field.rb, line 3 def initialize(builder, name, options, &block) @builder = builder @name = name @options = options @block = block end
Public Instance Methods
render()
click to toggle source
# 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
Private Instance Methods
help_block()
click to toggle source
# File lib/miniform/field.rb, line 42 def help_block unless @options[:error] == false @builder.help_block(@name) end end
input_wrapper(&block)
click to toggle source
# File lib/miniform/field.rb, line 48 def input_wrapper(&block) @builder.content_tag(:div, class: "col-md-9", &block) end
label()
click to toggle source
# File lib/miniform/field.rb, line 34 def label if vertical? @builder.label(@name, @options[:label]) else @builder.label(@name, @options[:label], class: "col-md-3") end end
should_omit_label?()
click to toggle source
# File lib/miniform/field.rb, line 30 def should_omit_label? @options.key?(:label) && !@options[:label] end
vertical?()
click to toggle source
# File lib/miniform/field.rb, line 26 def vertical? @builder.is_a?(VerticalFormBuilder) end