aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-05-16 20:52:27 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-05-16 20:53:28 -0300
commit982ed06b3ab963bd3bd0beb50f948bba803fdc4c (patch)
tree7fd554f7b7734088eca2ce083145f95e861b6139 /actionpack/lib
parent6f04975272c901e59fe0f062ca76680c5cebfe6b (diff)
downloadrails-982ed06b3ab963bd3bd0beb50f948bba803fdc4c.tar.gz
rails-982ed06b3ab963bd3bd0beb50f948bba803fdc4c.tar.bz2
rails-982ed06b3ab963bd3bd0beb50f948bba803fdc4c.zip
Make :prompt work as documented
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb9
-rw-r--r--actionpack/lib/action_view/helpers/tags/base.rb3
2 files changed, 9 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index df7ad7fd09..35015ba4d2 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -507,7 +507,10 @@ module ActionView
end
body = "".html_safe
- body.safe_concat content_tag(:option, prompt, :value => "") if prompt
+
+ if prompt
+ body.safe_concat content_tag(:option, prompt_text(prompt), :value => "")
+ end
grouped_options = grouped_options.sort if grouped_options.is_a?(Hash)
@@ -732,6 +735,10 @@ module ActionView
def value_for_collection(item, value)
value.respond_to?(:call) ? value.call(item) : item.send(value)
end
+
+ def prompt_text(prompt)
+ prompt = prompt.kind_of?(String) ? prompt : I18n.translate('helpers.select.prompt', :default => 'Please select')
+ end
end
class FormBuilder
diff --git a/actionpack/lib/action_view/helpers/tags/base.rb b/actionpack/lib/action_view/helpers/tags/base.rb
index 380ebe4b65..e077cd5b3c 100644
--- a/actionpack/lib/action_view/helpers/tags/base.rb
+++ b/actionpack/lib/action_view/helpers/tags/base.rb
@@ -140,8 +140,7 @@ module ActionView
option_tags = content_tag('option', options[:include_blank].kind_of?(String) ? options[:include_blank] : nil, :value => '') + "\n" + option_tags
end
if value.blank? && options[:prompt]
- prompt = options[:prompt].kind_of?(String) ? options[:prompt] : I18n.translate('helpers.select.prompt', :default => 'Please select')
- option_tags = content_tag('option', prompt, :value => '') + "\n" + option_tags
+ option_tags = content_tag('option', prompt_text(options[:prompt]), :value => '') + "\n" + option_tags
end
option_tags
end