Class: ActionView::Helpers::FormBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/incomplete_date/form_builder.rb

Instance Method Summary collapse

Instance Method Details

#incomplete_date_select(method, options = {}, html_options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/incomplete_date/form_builder.rb', line 3

def incomplete_date_select(method, options = {}, html_options = {})
  date = @object.send(method) || (Date.today - 50.years)
  date = date.to_incomplete_date
  options.merge!(:prefix => @object_name, :include_blank => true)
  # TODO: The +year+ and +circa+ tags don't have the standard +id+ according to its names.
  @template.text_field_tag("#{@object_name}[#{method}][year]", date.year, :size => 5, :maxlength => 4) + ' ' +
  @template.select_month(date, options.merge(:field_name => "#{method}][month")) + ' ' +
  @template.select_day(date, options.merge(:field_name => "#{method}][day")) + ' ' +
  @template.check_box_tag("#{@object_name}[#{method}][circa]", '1', date.circa) + ' circa'
end