Class: RailsAdmin::Config::Fields::Types::Datetime

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_admin/config/fields/types/datetime.rb

Direct Known Subclasses

Date, Time, Timestamp

Constant Summary

Constants inherited from Base

Base::NAMED_INSTANCE_VARIABLES

Instance Attribute Summary

Attributes inherited from Base

#abstract_model, #defined, #name, #order, #parent, #properties, #root, #section

Instance Method Summary collapse

Methods inherited from Base

#association?, #eager_load_values, #editable?, #errors, #form_default_value, #generic_field_help, #generic_help, #initialize, #inverse_of, #method_name, #optional, #optional=, #optional?, #sort_column, #type, #type_css_class, #value, #virtual?

Methods included from Inspectable

#inspect

Methods included from Groupable

#group

Methods included from Hideable

#hidden?, #hide, included, #show

Methods included from Configurable

#has_option?, #register_deprecated_instance_option, #register_instance_option

Methods included from Proxyable

#bindings, #bindings=, #with

Constructor Details

This class inherits a constructor from RailsAdmin::Config::Fields::Base

Instance Method Details

#filter_optionsObject



25
26
27
28
29
# File 'lib/rails_admin/config/fields/types/datetime.rb', line 25

def filter_options
  super.merge(
    datetimepicker_options: datepicker_options,
  )
end

#form_valueObject



89
90
91
# File 'lib/rails_admin/config/fields/types/datetime.rb', line 89

def form_value
  value&.in_time_zone&.strftime('%FT%T') || form_default_value
end

#parse_input(params) ⇒ Object



17
18
19
# File 'lib/rails_admin/config/fields/types/datetime.rb', line 17

def parse_input(params)
  params[name] = parse_value(params[name]) if params[name]
end

#parse_value(value) ⇒ Object



13
14
15
# File 'lib/rails_admin/config/fields/types/datetime.rb', line 13

def parse_value(value)
  ::Time.zone.parse(value)
end