Class: ExtForm::Helpers::Tags::DtPicker

Inherits:
ActionView::Helpers::Tags::TextField
  • Object
show all
Defined in:
lib/ext_form/helpers/tags/dt_picker.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.field_typeObject



29
30
31
# File 'lib/ext_form/helpers/tags/dt_picker.rb', line 29

def self.field_type
  'text'
end

Instance Method Details

#renderObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ext_form/helpers/tags/dt_picker.rb', line 6

def render
  if value_before_type_cast(object).present?
    @options[:value] = value_before_type_cast(object).match(/\d{4}-\d{1,2}-\d{1,2}(\s\d{1,2}:\d{1,2}:\d{1,2})?/)
  end

  output = @template_object.(:div, nil, class: 'input-append') do
    [super,
     @template_object.(:span, nil, class: 'add-on') do
       @template_object.(:i, nil, data: {:'time-icon' => 'icon-time',
                                   :'date-icon' => 'icon-calendar'})
     end
    ].join.html_safe
  end

  html_options = {}
  add_default_name_and_id(html_options)

  output << @template_object.javascript_tag do
    "$(function(){$('##{html_options['id']}').trigger('dt_picker_load');});".html_safe
  end
  output.html_safe
end