Sha256: 21ca48f75e008cf11dc7ae671a1c39216d5a2b5a0208c12c60ec34e73e90bf77

Contents?: true

Size: 821 Bytes

Versions: 14

Compression:

Stored size: 821 Bytes

Contents

class DaterangeInput < FormtasticBootstrap::Inputs::StringInput

  def to_html
    bootstrap_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

14 entries across 14 versions & 1 rubygems

Version Path
fullstack-admin-0.2.26 app/inputs/daterange_input.rb
fullstack-admin-0.2.25 app/inputs/daterange_input.rb
fullstack-admin-0.2.24 app/inputs/daterange_input.rb
fullstack-admin-0.2.23 app/inputs/daterange_input.rb
fullstack-admin-0.2.22 app/inputs/daterange_input.rb
fullstack-admin-0.2.21 app/inputs/daterange_input.rb
fullstack-admin-0.2.20 app/inputs/daterange_input.rb
fullstack-admin-0.2.19 app/inputs/daterange_input.rb
fullstack-admin-0.2.18 app/inputs/daterange_input.rb
fullstack-admin-0.2.17 app/inputs/daterange_input.rb
fullstack-admin-0.2.16 app/inputs/daterange_input.rb
fullstack-admin-0.2.15 app/inputs/daterange_input.rb
fullstack-admin-0.2.14 app/inputs/daterange_input.rb
fullstack-admin-0.2.13 app/inputs/daterange_input.rb