From f7669cd8344a83485d01f94e7b5896616cd57f51 Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Sat, 24 Dec 2011 00:44:23 +0300 Subject: add ability to set a prompt string in include_blank option for date helpers, closes #4143 --- actionpack/lib/action_view/helpers/date_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 2806348337..cf24f27536 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -13,7 +13,7 @@ module ActionView # # * :prefix - overwrites the default prefix of "date" used for the select names. So specifying "birthday" # would give birthday[month] instead of date[month] if passed to the select_month method. - # * :include_blank - set to true if it should be possible to set an empty date. + # * :include_blank - set to true or to a prompt string if it should be possible to set an empty date. # * :discard_type - set to true if you want to discard the type part of the select name. If set to true, # the select_month method would use simply "date" (which can be overwritten using :prefix) instead # of "date[month]". @@ -887,7 +887,7 @@ module ActionView select_options.merge!(:disabled => 'disabled') if @options[:disabled] select_html = "\n" - select_html << content_tag(:option, '', :value => '') + "\n" if @options[:include_blank] + select_html << content_tag(:option, "#{ERB::Util.html_escape(@options[:include_blank]) if @options[:include_blank].kind_of?(String)}", :value => '') + "\n" if @options[:include_blank] select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt] select_html << select_options_as_html -- cgit v1.2.3