Module: SimpleForm::Bootstrap::FormBuilders::DateTime

Defined in:
lib/simple_form/bootstrap/form_builders/date_time.rb

Constant Summary collapse

DATE_TIME_COLUMN_TYPES =
[
  :datetime,
  'datetime',
  'timestamp',
  'timestamp without time zone'
].freeze
DATE_COLUMN_TYPES =
[
  :date,
  'date'
].freeze

Instance Method Summary collapse

Instance Method Details

#default_input_type(attribute_name, column, options, *args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/simple_form/bootstrap/form_builders/date_time.rb', line 14

def default_input_type(attribute_name, column, options, *args, &block)
  if (options.is_a?(Hash) ? options[:as] : @options[:as]).nil? && !column.nil?
    type = column.respond_to?(:type) ? column.type : column.sql_type
    return :bootstrap_date_time if DATE_TIME_COLUMN_TYPES.include?(type)
    return :bootstrap_date if DATE_COLUMN_TYPES.include?(type)
  end

  super(attribute_name, column, options, *args, &block)
end