aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Lee <davidomundo@gmail.com>2011-05-09 16:16:55 -0700
committerDavid Lee <davidomundo@gmail.com>2011-06-11 01:58:26 -0700
commitfa3fc520698092a002562107731b0d3b97e203d4 (patch)
tree4ce637740d4fde564d4e3e008175ff85fa1a62b5 /actionpack
parent1cbe917237c3f8e6bdcbe97835b26b55354b8566 (diff)
downloadrails-fa3fc520698092a002562107731b0d3b97e203d4.tar.gz
rails-fa3fc520698092a002562107731b0d3b97e203d4.tar.bz2
rails-fa3fc520698092a002562107731b0d3b97e203d4.zip
Make utf8 enforcer param customizeable
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/controller_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb13
-rw-r--r--actionpack/lib/action_view/railtie.rb7
3 files changed, 18 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/controller_helper.rb b/actionpack/lib/action_view/helpers/controller_helper.rb
index db59bca159..1a583e62ae 100644
--- a/actionpack/lib/action_view/helpers/controller_helper.rb
+++ b/actionpack/lib/action_view/helpers/controller_helper.rb
@@ -20,4 +20,4 @@ module ActionView
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 5c1a4ae483..dcc96c0168 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -17,6 +17,13 @@ module ActionView
include UrlHelper
include TextHelper
+ # You can change what the name will be for the hidden tag that forces utf8
+ # encoding for forms generated with Rails form helpers.
+ #
+ # ActionView::Helpers::FormTagHelper.utf8_enforcer_param = "_unicode"
+ mattr_accessor :utf8_enforcer_param
+ @@utf8_enforcer_param = "utf8"
+
# Starts a form tag that points the action to an url configured with <tt>url_for_options</tt> just like
# ActionController::Base#url_for. The method for the form defaults to POST.
#
@@ -611,8 +618,8 @@ module ActionView
end
def extra_tags_for_form(html_options)
- utf8_enforcer = tag(:input, :type => "hidden",
- :name => "utf8", :value => "&#x2713;".html_safe)
+ utf8_enforcer_tag = tag(:input, :type => "hidden",
+ :name => utf8_enforcer_param, :value => "&#x2713;".html_safe)
authenticity_token = html_options.delete("authenticity_token")
method = html_options.delete("method").to_s
@@ -629,7 +636,7 @@ module ActionView
tag(:input, :type => "hidden", :name => "_method", :value => method) + token_tag(authenticity_token)
end
- tags = utf8_enforcer << method_tag
+ tags = utf8_enforcer_tag << method_tag
content_tag(:div, tags, :style => 'margin:0;padding:0;display:inline')
end
diff --git a/actionpack/lib/action_view/railtie.rb b/actionpack/lib/action_view/railtie.rb
index 80391d72cc..b12aa4527b 100644
--- a/actionpack/lib/action_view/railtie.rb
+++ b/actionpack/lib/action_view/railtie.rb
@@ -8,6 +8,13 @@ module ActionView
config.action_view.stylesheet_expansions = {}
config.action_view.javascript_expansions = { :defaults => %w(jquery jquery_ujs) }
+ initializer "action_view.utf8_enforcer_param" do |app|
+ ActiveSupport.on_load(:action_view) do
+ param = app.config.action_view.delete(:utf8_enforcer_param)
+ ActionView::Helpers::FormTagHelper.utf8_enforcer_param = param
+ end
+ end
+
initializer "action_view.cache_asset_ids" do |app|
unless app.config.cache_classes
ActiveSupport.on_load(:action_view) do