Sha256: 0c9ec8d9d85e3600a34f2d9095e4c1b58ff2b1f8b8735e98b6c56ac8b0527e25
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module SimpleForm module Inputs class DateTimeInput < Base def input icon = input_html_options.delete(:icon) || 'glyphicon-calendar' icon_lib = input_html_options.delete(:iconlib) || icon.split('-')[0] defaultvalue = input_html_options.delete(:defaultvalue) if defaultvalue.present? && defaultvalue.is_a?(Hash) day_offset = defaultvalue.delete(:day_offset) defaulttime = Time.zone.now.change(defaultvalue) defaulttime += day_offset.days if day_offset.present? defaultvalue = defaulttime end input_html_options[:class] << 'dtp' no_group = if input_html_options.key?(:data) input_html_options[:data][:defaultvalue] = defaultvalue if defaultvalue.present? input_html_options[:data].key?(:no_group) else input_html_options[:data] = {:defaultvalue => defaultvalue} if defaultvalue.present? false end out = '' out << '<div class="input-group">' unless no_group out << @builder.text_field(attribute_name, input_html_options) unless no_group out << '<span class="input-group-addon">' out << "<span class='#{icon_lib} #{icon}'></span>" out << '</span>' out << '</div>' end out.html_safe end end end end
Version data entries
2 entries across 2 versions & 1 rubygems