Sha256: b5d2c5fd931b9f59c322b4590e25bed0ceaf7af9e77d3291d589e2cc67c83fb8

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module ExtForm
  module Helpers
    module Tags
      class DtPicker < ActionView::Helpers::Tags::TextField

        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.content_tag(:div, nil, class: 'input-append') do
            [super,
             @template_object.content_tag(:span, nil, class: 'add-on') do
               @template_object.content_tag(: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

        def self.field_type
          'text'
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ext_form-0.1.5 lib/ext_form/helpers/tags/dt_picker.rb