module Bh::Form::StaticControlHelper

Public Instance Methods

static_control(text_or_options_with_block = nil, options = {}, &block) click to toggle source
# File lib/bh/core_ext/rails/form/static_control_helper.rb, line 8
def static_control(text_or_options_with_block = nil, options = {}, &block)
  text, options = if block_given?
    [@template.capture(&block), text_or_options_with_block]
  else
    [text_or_options_with_block, options]
  end
  static_control_string text, options || {}
end

Private Instance Methods

static_control_string(text, options = {}) click to toggle source
# File lib/bh/core_ext/rails/form/static_control_helper.rb, line 19
def static_control_string(text, options = {})
  content_tag :div, class: 'form-group' do
    if inline_form?
        label = content_tag :label, options[:label], class: 'sr-only' if options[:label]
        field = content_tag :p, text, class: 'form-control-static'
        safe_join [label, field].compact
    elsif horizontal_form?
        label = content_tag :label, options[:label], class: 'col-sm-3 control-label' if options[:label]
        field = content_tag :p, text, class: 'form-control-static'
        if options[:label]
        field = content_tag :div, field, class: 'col-sm-9'
        else
          field = content_tag :div, field, class: 'col-sm-9 col-sm-offset-3'
        end
        safe_join [label, field].compact
    else
        label = content_tag :label, options[:label] if options[:label]
        field = content_tag :p, text, class: 'form-control-static'
        safe_join [label, field].compact
    end
  end
end