From fa3fc520698092a002562107731b0d3b97e203d4 Mon Sep 17 00:00:00 2001 From: David Lee Date: Mon, 9 May 2011 16:16:55 -0700 Subject: Make utf8 enforcer param customizeable --- actionpack/lib/action_view/helpers/controller_helper.rb | 2 +- actionpack/lib/action_view/helpers/form_tag_helper.rb | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_view/helpers') 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 url_for_options 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 => "✓".html_safe) + utf8_enforcer_tag = tag(:input, :type => "hidden", + :name => utf8_enforcer_param, :value => "✓".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 -- cgit v1.2.3