Module: SemanticGap::DateTimeForm::FormBuilderMixin

Defined in:
lib/semanticgap_date_time_form/form_builder_mixin.rb

Instance Method Summary collapse

Instance Method Details

#datetime_form(attr, value = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/semanticgap_date_time_form/form_builder_mixin.rb', line 4

def datetime_form(attr, value = nil)
  value ||= @object.try(datetime_param(attr))
  form = fields_for(datetime_param(attr), value) do |f|
    f.text_field(:year, :size => 4) + "/" +
      @template.select_month(value, :prefix => f.object_name, :include_blank => value.allow_blank?) + "/" +
      f.text_field(:day, :size => 2) + "—" +
      f.text_field(:hour, :size => 2) + ":" +
      f.text_field(:minute, :size => 2) +
      f.select(:ampm, %W(AM PM)) +
      @template.('span', value.time_zone.name, :class => 'timezone')
      # @template.time_zone_select(f.object_name, :time_zone_name, ActiveSupport::TimeZone.us_zones, :default => Time.zone.name)
  end

  @template.('div', form, :class => 'sg-datetime-form')
end