diff options
author | José Valim <jose.valim@gmail.com> | 2011-06-11 08:04:06 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-06-11 08:04:06 -0700 |
commit | 28f2b981fc0899e35ed0180376bddaa1b5bcaae8 (patch) | |
tree | 0ca44e76a1d1d8b989d8ab62ad73ccb790769cd2 /actionpack/lib/action_view | |
parent | 1829dd91757c5ac337b5e11323c693e75bf2f771 (diff) | |
parent | 9b305983e3518093f3b393a254f296ca2be29968 (diff) | |
download | rails-28f2b981fc0899e35ed0180376bddaa1b5bcaae8.tar.gz rails-28f2b981fc0899e35ed0180376bddaa1b5bcaae8.tar.bz2 rails-28f2b981fc0899e35ed0180376bddaa1b5bcaae8.zip |
Merge pull request #549 from dlee/utf8_enforcer
Utf8 enforcer param customization
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/controller_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 19 |
2 files changed, 16 insertions, 5 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 a91e86f4db..dd19fd2de9 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. # @@ -597,6 +604,13 @@ module ActionView number_field_tag(name, value, options.stringify_keys.update("type" => "range")) end + # Creates the hidden UTF8 enforcer tag. Override this method in a helper + # to customize the tag. If you just need to change the field name, set the + # +config.action_view.utf8_enforcer_param+ configuration option instead. + def utf8_enforcer_tag + tag(:input, :type => "hidden", :name => utf8_enforcer_param, :value => "✓".html_safe) + end + private def html_options_for_form(url_for_options, options, *parameters_for_url) options.stringify_keys.tap do |html_options| @@ -611,9 +625,6 @@ module ActionView end def extra_tags_for_form(html_options) - snowman_tag = tag(:input, :type => "hidden", - :name => "utf8", :value => "✓".html_safe) - authenticity_token = html_options.delete("authenticity_token") method = html_options.delete("method").to_s @@ -629,7 +640,7 @@ module ActionView tag(:input, :type => "hidden", :name => "_method", :value => method) + token_tag(authenticity_token) end - tags = snowman_tag << method_tag + tags = utf8_enforcer_tag << method_tag content_tag(:div, tags, :style => 'margin:0;padding:0;display:inline') end |