class SimpleBootstrapForm::HorizontalForm::Fields::DatetimeField

Creates a text field that should be initialized with jquery.datetimepicker

Public Instance Methods

input_tag() click to toggle source
# File lib/simple_bootstrap_form/horizontal_form/fields/datetime_field.rb, line 11
def input_tag
  @template.content_tag(:div, class: 'col-sm-6') do
    @template.content_tag :div, class: 'input-group' do
      @form_builder.text_field(@name, input_options) +
      calendar_icon
    end
  end
end

Private Instance Methods

calendar_icon() click to toggle source
# File lib/simple_bootstrap_form/horizontal_form/fields/datetime_field.rb, line 22
def calendar_icon
  @template.content_tag(:div, class: 'input-group-addon') do
    @template.content_tag(:span, '',
      class: 'glyphicon glyphicon-calendar',
      data: { 'activate-datepicker' => "##{tag_id}" }
    )
  end
end
input_options() click to toggle source
# File lib/simple_bootstrap_form/horizontal_form/fields/datetime_field.rb, line 31
def input_options
  super
  @options.merge! value: value_suitable_for_use_by_jquery_datetimepicker
  @options
end
sanitized_method_name() click to toggle source

Adapted from module ActionView::Helpers::Tags::Base

# File lib/simple_bootstrap_form/horizontal_form/fields/datetime_field.rb, line 52
def sanitized_method_name
  @name.to_s.sub(/\?$/,"")
end
sanitized_object_name() click to toggle source

Adapted from module ActionView::Helpers::Tags::Base

# File lib/simple_bootstrap_form/horizontal_form/fields/datetime_field.rb, line 47
def sanitized_object_name
  @form_builder.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
end
tag_id() click to toggle source

Adapted from module ActionView::Helpers::Tags::Base

# File lib/simple_bootstrap_form/horizontal_form/fields/datetime_field.rb, line 42
def tag_id
  "#{sanitized_object_name}_#{sanitized_method_name}"
end
value_suitable_for_use_by_jquery_datetimepicker() click to toggle source
# File lib/simple_bootstrap_form/horizontal_form/fields/datetime_field.rb, line 37
def value_suitable_for_use_by_jquery_datetimepicker
  @form_builder.object.send(@name).try(:strftime, '%Y/%m/%d %H:%M')
end