Class: ActiveAdminAddons::InputBase

Inherits:
Formtastic::Inputs::StringInput
  • Object
show all
Includes:
InputHtmlHelpers, InputMethods, InputOptionsHandler
Defined in:
lib/activeadmin_addons/support/input_base.rb

Instance Method Summary collapse

Methods included from InputHtmlHelpers

#build_hidden_control, #build_separator, #empty_input_id, #method_to_input_array_name, #method_to_input_id, #method_to_input_name, #prefixed_method, #selected_values_id

Methods included from InputMethods

#association_name, #build_virtual_attr, #input_related_items, #input_value, #method_model, #model_name, #object_class, #tableize_method, #translated_method, #url_from_method, #valid_method, #valid_object

Methods included from InputOptionsHandler

#attr_options, #control_attributes, #css_classes, #data_attr_options, #get_data_attr_value, #load_attr, #load_class, #load_data_attr

Instance Method Details

#concat(part) ⇒ Object



49
50
51
# File 'lib/activeadmin_addons/support/input_base.rb', line 49

def concat(part)
  parts << part
end

#input_html_optionsObject



22
23
24
25
26
27
# File 'lib/activeadmin_addons/support/input_base.rb', line 22

def input_html_options
  # maxwidth and size are added by Formtastic::Inputs::StringInput
  # but according to the HTML standard these are not valid attributes
  # on the inputs provided by this module
  super.except(:maxlength, :size).merge(control_attributes)
end

#load_control_attributesObject



37
38
39
# File 'lib/activeadmin_addons/support/input_base.rb', line 37

def load_control_attributes
  # Override on child classes if needed
end

#load_input_classObject



33
34
35
# File 'lib/activeadmin_addons/support/input_base.rb', line 33

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

#partsObject



45
46
47
# File 'lib/activeadmin_addons/support/input_base.rb', line 45

def parts
  @parts ||= []
end

#parts_to_htmlObject



29
30
31
# File 'lib/activeadmin_addons/support/input_base.rb', line 29

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

#render_custom_inputObject



41
42
43
# File 'lib/activeadmin_addons/support/input_base.rb', line 41

def render_custom_input
  # Override on child classes if needed
end

#to_htmlObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/activeadmin_addons/support/input_base.rb', line 11

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