Sha256: aa5cbebb11e206680c1cefff31521ea684cf8f482aa668d1627fb0dd693aebf2

Contents?: true

Size: 1.06 KB

Versions: 29

Compression:

Stored size: 1.06 KB

Contents

module Inputs
  module EffectiveDateTimePicker
    class Input < Effective::FormInput
      delegate :content_tag, :text_field_tag, :to => :@template

      def default_input_js
        {format: 'YYYY-MM-DD HH:mm', sideBySide: true}
      end

      def default_input_html
        {class: 'effective_date_time_picker datetime'}
      end

      def to_html
        if options[:input_group] == false
          return text_field_tag(field_name, value, tag_options)
        end

        content_tag(:div, class: 'input-group') do
          content_tag(:span, class: 'input-group-addon') do
            content_tag(:i, '', class: 'glyphicon glyphicon-calendar').html_safe
          end +
          text_field_tag(field_name, value, tag_options)
        end
      end

      def html_options
        super.tap do |html_options|
          if js_options[:format] == default_input_js[:format] # Unless someone changed from the default
            html_options[:pattern] = '\d{4}-\d{2}-\d{2} \d+:\d{2}' # Match default pattern defined above
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
effective_form_inputs-0.9.0 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.18 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.17 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.16 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.15 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.14 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.13 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.12 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.11 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.10 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.9 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.8 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.7 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.6 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.5 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.4 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.3 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.2 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.1 app/models/inputs/effective_date_time_picker/input.rb
effective_form_inputs-0.8.0 app/models/inputs/effective_date_time_picker/input.rb