Sha256: 7d8067bc5144237e8bb9b7ce73bce066e4e796ea355ce6370e37435c1ec562cc

Contents?: true

Size: 874 Bytes

Versions: 12

Compression:

Stored size: 874 Bytes

Contents

module ActiveAdminAddons
  class InputBase < Formtastic::Inputs::StringInput
    include InputOptionsHandler
    include InputMethods
    include InputHtmlHelpers

    def to_html
      load_input_class
      load_control_attributes
      render_custom_input
      if parts.any?
        return input_wrapping { parts_to_html }
      else
        super
      end
    end

    def input_html_options
      super.merge(control_attributes)
    end

    def parts_to_html
      parts.flatten.join("\n").html_safe
    end

    def load_input_class
      load_class(self.class.to_s.underscore.dasherize)
    end

    def load_control_attributes
      # Override on child classes if needed
    end

    def render_custom_input
      # Override on child classes if needed
    end

    def parts
      @parts ||= []
    end

    def concat(part)
      parts << part
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
activeadmin_addons-1.7.1 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.7.0 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.6.0 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.5.0 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.4.0 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.3.0 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.2.0 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.1.2 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.1.1 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.1.0 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.0.1 lib/activeadmin_addons/support/input_base.rb
activeadmin_addons-1.0.0 lib/activeadmin_addons/support/input_base.rb