From 17475bcbb71aba671d6ecb31ece0bc7fa21d3fe5 Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Tue, 7 Dec 2010 01:35:52 -0500 Subject: [PATCH] Rails now localizes the HTML5 placeholder attribute. [#6080 state:committed] --- actionpack/lib/action_view/helpers/form_helper.rb | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index ef5bbd8..8bb08b8 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -920,6 +920,10 @@ module ActionView options["type"] ||= field_type options["value"] = options.fetch("value"){ value_before_type_cast(object) } unless field_type == "file" options["value"] &&= ERB::Util.html_escape(options["value"]) + if options["placeholder"].blank? + i18n_placeholder = I18n.t("helpers.placeholder.#{object_name}.#{method_name}").presence + options["placeholder"] = ERB::Util.html_escape(i18n_placeholder) if i18n_placeholder.present? + end add_default_name_and_id(options) tag("input", options) end -- 1.6.5.2