Sha256: af2a60b608800551d9a5f82b0cdb2ec1a130edbfd789808ba1c7b857c0aadc06

Contents?: true

Size: 824 Bytes

Versions: 46

Compression:

Stored size: 824 Bytes

Contents

class DaterangeInput < FormtasticBootstrap::Inputs::StringInput

  def to_html
    generic_input_wrapping do
      [ builder.text_field(gt_input_name, input_html_options(gt_input_name)),
        template.content_tag(:span, "-", :class => "date-range-input-separator"),
        builder.text_field(lt_input_name, input_html_options(lt_input_name)),
      ].join("\n").html_safe
    end
  end

  def gt_input_name
    "#{method}_gte"
  end
  alias :input_name :gt_input_name

  def lt_input_name
    "#{method}_lte"
  end

  def input_html_options(input_name = gt_input_name)
    current_value = @object.send(input_name)
    { :size => 12,
      :class => "datepicker",
      :max => 10,
      :readonly => 'readonly',
      :value => current_value.respond_to?(:strftime) ? current_value.strftime("%Y-%m-%d") : "" }
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
fullstack-admin-0.2.12 app/inputs/daterange_input.rb
fullstack-admin-0.2.11 app/inputs/daterange_input.rb
fullstack-admin-0.2.9 app/inputs/daterange_input.rb
fullstack-admin-0.2.8 app/inputs/daterange_input.rb
fullstack-admin-0.2.7 app/inputs/daterange_input.rb
fullstack-admin-0.2.6 app/inputs/daterange_input.rb
fullstack-admin-0.2.5 app/inputs/daterange_input.rb
fullstack-admin-0.2.4 app/inputs/daterange_input.rb
fullstack-admin-0.2.3 app/inputs/daterange_input.rb
fullstack-admin-0.2.2 app/inputs/daterange_input.rb
fullstack-admin-0.2.1 app/inputs/daterange_input.rb
fullstack-admin-0.1.56 app/inputs/daterange_input.rb
fullstack-admin-0.1.55 app/inputs/daterange_input.rb
fullstack-admin-0.1.54 app/inputs/daterange_input.rb
fullstack-admin-0.1.53 app/inputs/daterange_input.rb
fullstack-admin-0.1.52 app/inputs/daterange_input.rb
fullstack-admin-0.1.51 app/inputs/daterange_input.rb
fullstack-admin-0.1.50 app/inputs/daterange_input.rb
fullstack-admin-0.1.49 app/inputs/daterange_input.rb
fullstack-admin-0.1.48 app/inputs/daterange_input.rb