lib/action_view/helpers/date_helper.rb in actionpack-1.11.2 vs lib/action_view/helpers/date_helper.rb in actionpack-1.12.0

- old
+ new

@@ -74,23 +74,23 @@ # :discard_day => true, :include_blank => true) # date_select("post", "written_on", :order => [:day, :month, :year]) # date_select("user", "birthday", :order => [:month, :day]) # # The selects are prepared for multi-parameter assignment to an Active Record object. - def date_select(object, method, options = {}) - InstanceTag.new(object, method, self).to_date_select_tag(options) + def date_select(object_name, method, options = {}) + InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_date_select_tag(options) end # Returns a set of select tags (one for year, month, day, hour, and minute) pre-selected for accessing a specified datetime-based # attribute (identified by +method+) on an object assigned to the template (identified by +object+). Examples: # # datetime_select("post", "written_on") # datetime_select("post", "written_on", :start_year => 1995) # # The selects are prepared for multi-parameter assignment to an Active Record object. - def datetime_select(object, method, options = {}) - InstanceTag.new(object, method, self).to_datetime_select_tag(options) + def datetime_select(object_name, method, options = {}) + InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_datetime_select_tag(options) end # Returns a set of html select-tags (one for year, month, and day) pre-selected with the +date+. def select_date(date = Date.today, options = {}) select_year(date, options) + select_month(date, options) + select_day(date, options) @@ -289,9 +289,19 @@ datetime_select << select_day(datetime, options_with_prefix.call(3)) unless options[:discard_day] || options[:discard_month] datetime_select << ' &mdash; ' + select_hour(datetime, options_with_prefix.call(4)) unless options[:discard_hour] datetime_select << ' : ' + select_minute(datetime, options_with_prefix.call(5)) unless options[:discard_minute] || options[:discard_hour] datetime_select + end + end + + class FormBuilder + def date_select(method, options = {}) + @template.date_select(@object_name, method, options.merge(:object => @object)) + end + + def datetime_select(method, options = {}) + @template.datetime_select(@object_name, method, options.merge(:object => @object)) end end end end