class WCC::Styles::SimpleForm::HistoricalDateInput

Public Instance Methods

input(wrapper_options=nil) click to toggle source
# File lib/wcc/styles/simple_form/historical_date_input.rb, line 4
def input(wrapper_options=nil)
  input_html_classes.unshift('date')
  common_options = {
    prefix: object_name,
    prompt: "",
  }.merge(merge_wrapper_options(input_html_options, wrapper_options))

  template.content_tag(:div, class: "row") do
    date_select_component(:month, common_options.merge(options[:month_input] || {})) +
      date_select_component(:day, common_options.merge(options[:day_input] || {})) +
      date_select_component(:year, common_options.merge(options[:year_input] || {}))
  end
end

Private Instance Methods

component_id(component) click to toggle source
# File lib/wcc/styles/simple_form/historical_date_input.rb, line 35
def component_id(component)
  case component
  when :year
    "1i"
  when :month
    "2i"
  when :day
    "3i"
  end
end
date() click to toggle source
# File lib/wcc/styles/simple_form/historical_date_input.rb, line 46
def date
  object.public_send(attribute_name)
end
date_select_component(component, options) click to toggle source
# File lib/wcc/styles/simple_form/historical_date_input.rb, line 20
def date_select_component(component, options)
  template.content_tag(:div, class: "col4") do
    template.content_tag(:div, class: "select-style") do
      template.concat(
        template.public_send(
          "select_#{component}",
          date,
          options.merge(field_name: "#{attribute_name}(#{component_id(component)})"),
          input_html_options
        )
      )
    end
  end
end