Module: BootstrapDatepicker::FormHelper

Includes:
ActionView::Helpers::JavaScriptHelper
Included in:
DatepickerHelper
Defined in:
lib/app/helpers/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#datepicker(object_name, method, options = {}, timepicker = false) ⇒ Object

Mehtod that generates datepicker input field inside a form



9
10
11
12
13
14
15
16
17
# File 'lib/app/helpers/form_helper.rb', line 9

def datepicker(object_name, method, options = {}, timepicker = false)
  input_tag =  BootstrapDatepicker::InstanceTag.new(object_name, method, self, options.delete(:object))
  dp_options, tf_options =  input_tag.baked_options(options)
  # tf_options[:value] = input_tag.format_date(tf_options[:value], String.new(dp_options[:dateFormat])) if  tf_options[:value] && !tf_options[:value].empty? && dp_options.has_key?(:dateFormat)
  html = input_tag.to_input_field_tag("text", tf_options)
  method = timepicker ? "datetimepicker" : "datepicker"
  # html += javascript_tag("jQuery(document).ready(function(){jQuery('##{input_tag.get_name_and_id["id"]}').#{method}(#{dp_options.to_json})});")
  html.html_safe
end