Sha256: 1c344e2b0306dd6e1ca120e4960ea86d6a513b6531410bcbc889bebfcd0169f0

Contents?: true

Size: 1.72 KB

Versions: 5

Compression:

Stored size: 1.72 KB

Contents

module Formnestic
  module Inputs
    module Base
      module Wrapping
        def input_wrapping(&block)
          if builder.options[:display_type] == 'table'
            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

        def table_date_select_input_wrapping(&block)
          builder
            .options[:parent_builder]
            .add_table_header(
              attributized_method_name,
              self.class,
              label_text
            )
          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

        def table_input_wrapping(&block)
          builder
            .options[:parent_builder]
            .add_table_header(
              attributized_method_name,
              self.class,
              label_text
            )

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
formnestic-1.0.7 lib/formnestic/inputs/base/wrapping.rb
formnestic-1.0.6 lib/formnestic/inputs/base/wrapping.rb
formnestic-1.0.5 lib/formnestic/inputs/base/wrapping.rb
formnestic-1.0.4 lib/formnestic/inputs/base/wrapping.rb
formnestic-1.0.3 lib/formnestic/inputs/base/wrapping.rb