module Formnestic::Inputs::Base::Wrapping

Public Instance Methods

input_wrapping(&block) click to toggle source
# File lib/formnestic/inputs/base/wrapping.rb, line 27
def input_wrapping(&block)
  if table_builder?
    if [
      'Formtastic::Inputs::DateSelectInput',
      'Formtastic::Inputs::TimeSelectInput',
      'Formtastic::Inputs::DateTimeSelectInput',
      'Formtastic::Inputs::TimeInput',
      'Formtastic::Inputs::DateInput'
    ].index(self.class.to_s)
      table_date_select_input_wrapping(&block)
    else
      table_input_wrapping(&block)
    end
  else
    formtastic_input_wrapping(&block)
  end
end
parent_table_builder?() click to toggle source
# File lib/formnestic/inputs/base/wrapping.rb, line 17
def parent_table_builder?
  if builder.options[:parent_builder]
    builder
      .options[:parent_builder]
      .options[:display_type] == 'table'
  else
    false
  end
end
table_builder?() click to toggle source
# File lib/formnestic/inputs/base/wrapping.rb, line 6
def table_builder?
  builder.options[:display_type] == 'table' ||
    if builder.options[:parent_builder]
      builder
        .options[:parent_builder]
        .options[:display_type] == 'table'
    else
      false
    end
end
table_date_select_input_wrapping(&block) click to toggle source
# File lib/formnestic/inputs/base/wrapping.rb, line 45
def table_date_select_input_wrapping(&block)
  unless parent_table_builder?
    builder
      .options[:parent_builder]
      .add_table_header(
        attributized_method_name,
        self.class,
        label_text
      )
  end

  template.content_tag(
    :td,
    template.content_tag(
      :div, [
        template.capture(&block), error_html, hint_html
      ].join("\n").html_safe,
      class: 'table-date-select-container'
    ), wrapper_html_options
  )
end
table_input_wrapping(&block) click to toggle source
# File lib/formnestic/inputs/base/wrapping.rb, line 67
def table_input_wrapping(&block)
  unless parent_table_builder?
    builder
      .options[:parent_builder]
      .add_table_header(
        attributized_method_name,
        self.class,
        label_text
      )
  end

  template.content_tag(
    :td,
    [
      template.capture(&block),
      error_html,
      hint_html
    ].join("\n").html_safe,
    wrapper_html_options
  )
end