Class: DaterangeInput

Inherits:
FormtasticBootstrap::Inputs::StringInput
  • Object
show all
Defined in:
app/inputs/daterange_input.rb

Instance Method Summary collapse

Instance Method Details

#gt_input_nameObject Also known as: input_name



12
13
14
# File 'app/inputs/daterange_input.rb', line 12

def gt_input_name
  "#{method}_gte"
end

#input_html_options(input_name = gt_input_name) ⇒ Object



21
22
23
24
25
26
27
28
# File 'app/inputs/daterange_input.rb', line 21

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

#lt_input_nameObject



17
18
19
# File 'app/inputs/daterange_input.rb', line 17

def lt_input_name
  "#{method}_lte"
end

#to_htmlObject



3
4
5
6
7
8
9
10
# File 'app/inputs/daterange_input.rb', line 3

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