aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_options_helper.rb
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/action_view/helpers/form_options_helper.rb
parent6f04975272c901e59fe0f062ca76680c5cebfe6b (diff)
downloadrails-982ed06b3ab963bd3bd0beb50f948bba803fdc4c.tar.gz
rails-982ed06b3ab963bd3bd0beb50f948bba803fdc4c.tar.bz2
rails-982ed06b3ab963bd3bd0beb50f948bba803fdc4c.zip
Make :prompt work as documented
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_options_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb9
1 files changed, 8 insertions, 1 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