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

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

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



12
13
14
15
16
17
18
19
# File 'lib/simple_form/bootstrap/form_builders/date_time.rb', line 12

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

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