Sha256: c2524285d2a4d7c72762539a3f545a818bc3f95fda5809def7e3a58d5d96ed98

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
class DateTimeInput < SimpleForm::Inputs::DateTimeInput
  def input(wrapper_options)
    add_autocomplete!
    input_html_options.merge(input_options)
    input_html_options[:value] = value
    @builder.text_field(attribute_name, merge_wrapper_options(input_html_options, wrapper_options))
  end

  def label_target
    attribute_name
  end

  private

  def has_required?
    options[:required]
  end

  def add_autocomplete!
    input_html_options[:autocomplete] ||= 'off'
  end

  # Serialize into a value recognised by datepicker, also sorts out timezone conversion
  #------------------------------------------------------------------------------
  def value
    val = object.send(attribute_name)
    val.present? ? val.strftime('%Y-%m-%d %H:%M') : nil
  end

  ActiveSupport.run_load_hooks(:fat_free_crm_date_time_input, self)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fat_free_crm-0.22.1 app/inputs/date_time_input.rb
fat_free_crm-0.22.0 app/inputs/date_time_input.rb
fat_free_crm-0.21.0 app/inputs/date_time_input.rb
fat_free_crm-0.20.1 app/inputs/date_time_input.rb
fat_free_crm-0.20.0 app/inputs/date_time_input.rb
fat_free_crm-0.19.2 app/inputs/date_time_input.rb
fat_free_crm-0.19.0 app/inputs/date_time_input.rb
fat_free_crm-0.18.2 app/inputs/date_time_input.rb
fat_free_crm-0.17.3 app/inputs/date_time_input.rb
fat_free_crm-0.18.1 app/inputs/date_time_input.rb
fat_free_crm-0.18.0 app/inputs/date_time_input.rb
fat_free_crm-0.17.2 app/inputs/date_time_input.rb
fat_free_crm-0.17.1 app/inputs/date_time_input.rb