Class: ColorInput

Inherits:
SimpleForm::Inputs::Base
  • Object
show all
Defined in:
app/inputs/color_input.rb

Instance Method Summary collapse

Instance Method Details

#input(wrapper_options) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'app/inputs/color_input.rb', line 2

def input(wrapper_options)
  hex_code = object.try(attribute_name).presence || options.delete(:hex_code).presence || options.delete(:default).presence || default_hex_code
  merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
  merged_input_options.merge!(type: :color, value: hex_code)

  content = ActiveSupport::SafeBuffer.new
  content << (:div, input_group(hex_code, merged_input_options), class: 'input-group')
  content << (:div, default_help_text)
  content
end