Sha256: 4cfb1656a5d729fda22d84275e25e4dba54a9aada9d43df3c9077365acda6e77

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

module FormtasticRebootstrap
  module Inputs
    module Base
      module Html

        include Formtastic::Inputs::Base::Html

        def form_control_input_html_options
          new_classes = input_class_without_col&.compact&.join(" ")
          input_html_options.merge(:class => new_classes)
        end

        def original_classes
          input_html_options[:class]&.split(' ')&.flatten
        end

        def input_class_without_col
          ['form-control'] <<  original_classes&.reject do |c|
            c.match(/^col-(sm|md|lg|xl)?-?[0-9]{1,2}/)
          end&.join(' ')
        end

        def input_html_options
          if errors?
            {
              :class => "error"
            }.merge(super)
          else
            super
          end
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
formtastic_rebootstrap-0.0.2 lib/formtastic_rebootstrap/inputs/base/html.rb
formtastic_rebootstrap-0.0.1 lib/formtastic_rebootstrap/inputs/base/html.rb