Module: FormtasticBootstrap::Inputs::Base::Timeish

Included in:
DateSelectInput, DatetimeSelectInput, TimeSelectInput
Defined in:
lib/formtastic-bootstrap/inputs/base/timeish.rb

Instance Method Summary collapse

Instance Method Details

#controls_wrapper_html_optionsObject



18
19
20
21
22
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 18

def controls_wrapper_html_options
  super.tap do |options|
    options[:class] = (options[:class].split << "controls-row").join(" ")
  end
end

#fragment_class(fragment) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 37

def fragment_class(fragment) 
  { 
    :year   => "span1", 
    :month  => "span2",
    :day    => "span1",
    :hour   => "span1",
    :minute => "span1",
    :second => "span1"
  }[fragment]
end

#fragment_input_html(fragment) ⇒ Object



24
25
26
27
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 24

def fragment_input_html(fragment)
  opts = input_options.merge(:prefix => fragment_prefix, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
  template.send(:"select_#{fragment}", value, opts, fragment_input_html_options(fragment))
end

#fragment_input_html_options(fragment) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 29

def fragment_input_html_options(fragment)
  input_html_options.tap do |options|
    options[:id] = fragment_id(fragment)
    options[:class] = ((options[:class] || "").split << fragment_class(fragment)).join(" ")
    options[:placeholder] = fragment_placeholder(fragment)
  end
end

#fragment_placeholder(fragment) ⇒ Object



48
49
50
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 48

def fragment_placeholder(fragment)
  "." + fragment_class(fragment) 
end

#to_htmlObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/formtastic-bootstrap/inputs/base/timeish.rb', line 6

def to_html
  control_group_wrapping do
    control_label_html <<
    controls_wrapping do
      hidden_fragments <<
      fragments.map do |fragment|
        fragment_input_html(fragment)
      end.join.html_safe
    end
  end
end