Sha256: a75c1d019df852d46de1196de65276206eb2e10a8afde197cf6c72bb0c0cc00f

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

# 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.merge!(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

6 entries across 6 versions & 2 rubygems

Version Path
fat_free_crm-0.14.2 app/inputs/date_time_input.rb
fat_free_crm-0.14.1 app/inputs/date_time_input.rb
fat_free_crm-0.15.0.beta app/inputs/date_time_input.rb
fat_free_crm-0.14.0 app/inputs/date_time_input.rb
reduced_fat_crm-0.15.0.beta app/inputs/date_time_input.rb
reduced_fat_crm-0.14.0 app/inputs/date_time_input.rb