Class: SimpleForm::Inputs::DateTimeInput

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/backend/form_builder.rb

Instance Method Summary collapse

Instance Method Details

#input(_wrapper_options = nil) ⇒ Object


833
834
835
836
# File 'app/helpers/backend/form_builder.rb', line 833

def input(_wrapper_options = nil)
  @builder.text_field(attribute_name, input_html_options)
  # @builder.send("#{input_type}_field", attribute_name, input_html_options)
end

#input_html_optionsObject


803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
# File 'app/helpers/backend/form_builder.rb', line 803

def input_html_options
  value = object.send(attribute_name)
  # format = @options[:format] || :default
  # unless format.is_a?(Symbol)
  #   raise ArgumentError, "Option :format must be a Symbol referencing a translation 'date.formats.<format>'"
  # end
  # if localized_value = value
  #   localized_value = localized_value.l(format: format)
  # end
  # format = I18n.translate("#{input_type == :datetime ? :time : input_type}.formats.#{format}")
  # # format = I18n.translate("time.formats.#{format}")
  # Formize::DATE_FORMAT_TOKENS.each{|js, rb| format.gsub!(rb, js)}
  # Formize::TIME_FORMAT_TOKENS.each{|js, rb| format.gsub!(rb, js)}
  options = {
    # data: {
    #   format: format,
    #   human_value: localized_value
    # },
    lang: 'i18n.iso2'.t,
    value: value.blank? ? nil : value.l(format: "%Y-%m-%d#{' %H:%M' if input_type == :datetime}"),
    type: input_type,
    size: @options.delete(:size) || (input_type == :date ? 10 : 16)
  }
  super.merge options
end

#label_targetObject


829
830
831
# File 'app/helpers/backend/form_builder.rb', line 829

def label_target
  super
end