Sha256: 12b4b8a6d872466e24ed3cbdca97a5a463e2feae760c765c49f4009619c6b29b

Contents?: true

Size: 807 Bytes

Versions: 13

Compression:

Stored size: 807 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 => "seperator"),
        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

13 entries across 13 versions & 1 rubygems

Version Path
fullstack-admin-0.1.18 app/inputs/daterange_input.rb
fullstack-admin-0.1.17 app/inputs/daterange_input.rb
fullstack-admin-0.1.16 app/inputs/daterange_input.rb
fullstack-admin-0.1.15 app/inputs/daterange_input.rb
fullstack-admin-0.1.14 app/inputs/daterange_input.rb
fullstack-admin-0.1.12 app/inputs/daterange_input.rb
fullstack-admin-0.1.11 app/inputs/daterange_input.rb
fullstack-admin-0.1.10 app/inputs/daterange_input.rb
fullstack-admin-0.1.8 app/inputs/daterange_input.rb
fullstack-admin-0.1.7 app/inputs/daterange_input.rb
fullstack-admin-0.1.5 app/inputs/daterange_input.rb
fullstack-admin-0.1.3 app/inputs/daterange_input.rb
fullstack-admin-0.1.1 app/inputs/daterange_input.rb